MySQL and MariaDB are some of the most popular database managers out there. Thanks to their deep stability and the fact that they are free and open source. But I think the fact that they are so popular is that they are heavily documented by the community. So if you have a problem, you can probably solve it on the internet. However, managing a MySQL or MariaDB server without the help of a third-party graphics application can be uncomfortable. Even more so if you are a newbie. Then, tools like PHPMyAdmin become necessary. In this post, you will learn how to install the latest version of PHPMyAdmin on Debian 10.
Some features of PHPMyAdmin
PHPMyAdmin is a web application that is installed on a server to manage a MySQL or MariaDB instance. These are some of the main features:
- Intuitive web interface.
- Support for most MySQL features:
- browse and drop databases, tables, views, fields and indexes.
- create, copy, drop, rename and alter databases, tables, fields and indexes.
- maintenance server, databases and tables, with proposals on server configuration.
- execute, edit and bookmark any SQL-statement, even batch-queries.
- manage MySQL user accounts and privileges.
- manage stored procedures and triggers.
- Import data from CSV and SQL.
- Export data to various formats: CSV, SQL, XML, PDF, ISO/IEC 26300 – OpenDocument Text and Spreadsheet, Word, and others.
Install PHPMyAdmin on Debian 10 Buster
1) Install LAMP on Debian 10
As it is a web application, it requires a fully functional LAMP server. Of course, PHPMyAdmin is compatible with Nginx but in this case, we will focus on Apache.
Then, install LAMP on Debian 10. For that, we have a tutorial to help you with that:
Read, How to install LAMP on Debian 10 Buster?
After that, you can continue with the installation.
2) Download and install PHPMyAdmin on Debian 10
At the time of writing this post, the latest stable version of PHPMyAdmin is 4.9.0.1. You can always go to the project website and check which is the latest stable version.
Now we proceed to download it:
:~$ cd /tmp/ :~$ wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz
Next, decompress it and move it to /usr/share/phpmyadmin
.
:~$ tar xvf phpMyAdmin-4.9.0.1-all-languages.tar.gz :~$ sudo mv phpMyAdmin-4.9.0.1-all-languages /usr/share/phpmyadmin
For PHPMyAdmin to work properly it is necessary to create a temporary folder dedicated to the application.
:~$ sudo mkdir -p /var/lib/phpmyadmin/tmp :~$ sudo chown -R www-data:www-data /var/lib/phpmyadmin
Then, create the configuration folder for PHPMyAdmin and copy the default configuration file into it.
:~$ sudo mkdir /etc/phpmyadmin/ :~$ sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
A passphrase must be defined in the PHPMyAdmin configuration file. It is also necessary to indicate which is the path of the newly created PHPMyAdmin temporary folder.
:~$ sudo nano /usr/share/phpmyadmin/config.inc.php
$cfg['blowfish_secret'] = '[passphrase]'; $cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
Save the changes and close the file.
The next step is to create a new virtual host to make PHPMyAdmin work fully. To do this, create a new file and paste the following:
:~$ sudo nano /etc/apache2/conf-enabled/phpmyadmin.conf
Alias /phpmyadmin /usr/share/phpmyadmin <Directory /usr/share/phpmyadmin> Options SymLinksIfOwnerMatch DirectoryIndex index.php <IfModule mod_php5.c> <IfModule mod_mime.c> AddType application/x-httpd-php .php </IfModule> <FilesMatch ".+\.php$"> SetHandler application/x-httpd-php </FilesMatch> php_value include_path . php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/ php_admin_value mbstring.func_overload 0 </IfModule> <IfModule mod_php.c> <IfModule mod_mime.c> AddType application/x-httpd-php .php </IfModule> <FilesMatch ".+\.php$"> SetHandler application/x-httpd-php </FilesMatch> php_value include_path . php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/ php_admin_value mbstring.func_overload 0 </IfModule> </Directory> <Directory /usr/share/phpmyadmin/setup> <IfModule mod_authz_core.c> <IfModule mod_authn_file.c> AuthType Basic AuthName "phpMyAdmin Setup" AuthUserFile /etc/phpmyadmin/htpasswd.setup </IfModule> Require valid-user </IfModule> </Directory> <Directory /usr/share/phpmyadmin/templates> Require all denied </Directory> <Directory /usr/share/phpmyadmin/libraries> Require all denied </Directory> <Directory /usr/share/phpmyadmin/setup/lib> Require all denied </Directory>
Save the changes and close the file.
Next enable the new virtualhost.
:~$ sudo a2enmod rewrite :~$ sudo systemctl restart apache2
Now you can open your web browser and go to http://your-server/phpmyadmin
. You will see this:
So, that is it.
Conclusion
PHPMyAdmin is a simple, fast and easy to install the application with which managing a MySQL or MariaDB instance becomes much easier. It is of great help to both novices and more experienced developers.
Please share this post and join our Telegram channel.
“Then, create the configuration folder for PHPMyAdmin and copy the default configuration file into it.”
:~$ sudo mkdir /etc/phpmyadmin/
:~$ sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
Which of the commands puts the configuration file into the folder created?
The second