Oct 12, 2021
How to Install phpMyAdmin on Ubuntu 18.04
MySQL is a free and open-source relational database management system, widely used in many typical applications. It is an integral part of LAMP web application stack which also includes Apache – a free open-source, cross-platform web server.
Although you can do everything through the command line interface, some people prefer using a GUI or Graphical User Interface to work on databases.
That brings us to phpMyAdmin. The phpMyAdmin is a free and open-source GUI tool to manage MySQL databases. Although it is relatively easy to install phpMyAdmin on Ubuntu server, the procedure changed quite a bit with the release of Ubuntu OS version 18.04 where root user access for applications was disabled due to security concerns.
In this article, you will learn how to install phpMyAdmin on Ubuntu 18.04 running an Apache server with MySQL database.
In order to install phpMyAdmin you should have an Apache server with MySQL database up and running on Ubuntu 18.04 OS. You should also be familiar with the command line interface.
Install phpMyAdmin on Ubuntu 18.04
The installation procedure is fairly easy if you have the mentioned applications working smoothly.
Open up command line interface, and access your VPS using SSH. Having trouble? Check out our PuTTY tutorial!
Afterwards, issue the command:
sudo apt-get install phpmyadmin php-mbstring php-gettext –y
Note that during the installation process, you will be asked to select a web server. Select apache2 by pressing Space and then Tab key and press enter key to continue.
You will then be asked for a database configuration. Select Yes and continue further.
Set a “MySQL application password for phpmyadmin”. Make sure to use a strong and unique password. Verify again when prompted.
Finally, enter the database admin user password.
When the installation procedure is complete, open your browser and point the URL to http://SERVER_IP/phpmyadmin (where SERVER_IP is the IP address of your server).
In case you use localhost, use the http://localhost/phpmyadmin URL and log in.
Note that on Ubuntu 18.04, you cannot log in as root user due to security issues. So login with the username phpmyadmin and MySQL password you set earlier.
Now here’s a thing, immediately upon logging you will discover that the phpMyAdmin interface has very limited options available. To make this phpMyAdmin UI a practical solution, we must grant some permissions to the phpmyadmin user.
Granting Permissions to “phpmyadmin” user
Open command line interface and log in to MySQL with the command:
sudo mysql -u root –p
Grant permissions to the phpmyadmin user with these commands:
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost'; FLUSH PRIVILEGES; EXIT
Now log out of the phpMyAdmin if you’re still logged in and log in again with the same phpmyadmin username you used earlier. You’ll now have full privileges for MySQL.
For security reasons, if you don’t want to use or work with phpmyadmin default user account then you can create a new MySQL admin user with full privileges. Just write these commands in the command line interface:
CREATE USER USERNAME IDENTIFIED by 'PASSWORD'; GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost'; FLUSH PRIVILEGES; EXIT
Note that the USERNAME and PASSWORD should be unique and strong. Again replace username on the second line with the username you created on the first one. All the commands should be executed one line at a time.
Restart the Apache server if you encounter any problems logging in. The command to restart server is:
sudo service apache2 restart
It is recommended to take a look at the “Status” tab, which will display a number of connections to the MySQL server, current MySQL queries that are running on the server, and the server uptime.
That’s all! You’ve successfully installed and setup phpMyAdmin on Ubuntu 18.04 with proper administration permissions granted. Now you can start working with some of its more advanced features. Check out the official phpMyadmin documentation for more. Stay tuned!