Install MySQL with phpMyAdmin on Ubuntu

There are hundreds of articles on how to install phpMyAdmin on Ubuntu. However, none of them showed me an error-free way of installing phpMyAdmin in my system. This article is for those who want to install phpMyAdmin and MySQL without any errors.

phpMyAdmin depends on Apache Server, PHP, and MySQL. Therefore, I recommend to install them before installing phpMyAdmin.

Step 1:
Execute the following command from the terminal, to install Apache Server.
sudo apt install apache2

Step 2:
Start Apache server using the following command and visit http://localhost to see whether the Apache Server works. If you get "Apache2 Ubuntu Default Page", your Apache Server is ready.
sudo service apache2 start

Step 3:
Install PHP along with additional modules which are required by phpMyAdmin.
sudo apt install php php-gettext libapache2-mod-php

Step 4:
Install MySQL.
sudo apt install mysql-server

Step 5:
Try to login to MySQL using mysql -u root. If you get an error message saying "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)", follow this step. Otherwise, continue from Step 6.

5.1: Login to MySQL with sudo.
sudo mysql -u root

5.2: Select the mysql database.
mysql> USE mysql;

5.3: Update the databse to use mysql_native_password plugin for root user.
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';

5.4: Exit MySQL.
mysql> exit;

5.5: Restart MySQL server.
sudo service mysql restart

Step 6:
Install phpMyAdmin.
sudo apt install phpmyadmin
  • Answer yes to "Configure database for phpmyadmin with dbconfig-common?"
  • Select apache2 (by pressing space) when asked to select "Web server to reconfigure automatically"

Step 7:
Restart Apache server.
sudo service apache2 restart

Step 8:
Visit http://localhost/phpmyadmin.

If you get the phpMyAdmin website, you are all set. If you get any errors while following this article, feel free to comment below. I will try my best to figure out the solution.
Next Post »

Contact Form


Email *

Message *