<\/span><\/h2>\nphpMyAdmin is already available in the default Ubuntu package repositories.<\/p>\n
To install phpMyAdmin, along will all of the required dependencies, run the following command:<\/p>\n
sudo apt install phpmyadmin<\/pre>\nDuring the installation, you will be asked a couple of questions.<\/p>\n
Choose apache2<\/code> as your web server:<\/p>\n<\/p>\n
Choose <Yes><\/code> to configure a database for phpMyAdmin with dbconfig-common:<\/code><\/p>\n<\/p>\n
Enter and confirm a MySQL application password for phpMyAdmin:<\/p>\n
<\/p>\n
With this last step, the phpMyAdmin installation has been completed.<\/p>\n
To\u00a0access your phpMyAdmin, first restart your apache2 web server with:<\/p>\n
systemctl\u00a0restart apache2<\/pre>\nand type\u00a0http:\/\/yourIPaddress\/phpmyadmin<\/span><\/code> in your browser to access the login page:<\/p>\n<\/p>\n
<\/span>Step 3: phpMyAdmin Login<\/span><\/h2>\nTo manage your databases using phpMyAdmin, you will need to either log in as the MySQL\u00a0root user\u00a0or as another MySQL user account with administrative privileges. We will show you how to log in using both of these methods.<\/p>\n
Log in as root<\/h3>\n
By default, the root user is set to use\u00a0the\u00a0auth_socket<\/strong> plugin in order to authenticate to your MySQL database server. If you want to be able to authenticate as the root user in your phpMyAdmin, you will have to change the authentication method from\u00a0auth_socket\u00a0<\/strong>to\u00a0mysql_native_password.<\/strong><\/p>\nTo do this, connect to your server via SSH, and then log in to your MySQL database server by typing the following command:<\/p>\n
sudo mysql<\/pre>\nThis will take you to the MySQL shell as the MySQL root user. To check the authentication method of all of your users, you can execute the following:<\/p>\n
SELECT user,plugin FROM mysql.user;<\/pre>\nYou will get the following output on your screen:<\/p>\n
+------------------+-----------------------+\r\n| user | plugin |\r\n+------------------+-----------------------+\r\n| root | auth_socket |\r\n| mysql.session | mysql_native_password |\r\n| mysql.sys | mysql_native_password |\r\n| debian-sys-maint | mysql_native_password |\r\n| phpmyadmin | mysql_native_password |\r\n+------------------+-----------------------+<\/pre>\nIn order to change the authentication plugin from\u00a0auth_socket\u00a0<\/strong>to\u00a0mysql_native_password\u00a0<\/strong>for your root user, you will need to run the following:<\/p>\nALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'STRONG_PASSWORD<\/span>';<\/pre>\nMake sure that you replace the\u00a0STRONG_PASSWORD\u00a0<\/span>part with an actual strong password that you would like to use for your MySQL root user.<\/p>\nAfter this is done, you will need to flush all privileges in order for the changes to take effect:<\/p>\n
FLUSH PRIVILEGES;<\/pre>\nYou can then run the same command again to check if the authentication method has been successfully updated:<\/p>\n
SELECT user,plugin FROM mysql.user;<\/pre>\nOutput:<\/p>\n
+------------------+-----------------------+\r\n| user | plugin |\r\n+------------------+-----------------------+\r\n| root | mysql_native_password |\r\n| mysql.session | mysql_native_password |\r\n| mysql.sys | mysql_native_password |\r\n| debian-sys-maint | mysql_native_password |\r\n| phpmyadmin | mysql_native_password |\r\n+------------------+-----------------------+<\/pre>\nTo disconnect from the MySQL database server, you can type:<\/p>\n
exit;<\/pre>\nYou can now use your MySQL user to log in to your phpMyAdmin and manage your databases.<\/p>\n
Create a new admin user<\/h3>\n
Another option is to create a new MySQL user with administrative privileges. We will show you how to create a new user called “admin” which you can use to log in to your phpMyAdmin.<\/p>\n
To create this new user, once again log in to your MySQL database server with:<\/p>\n
sudo mysql<\/pre>\nAnd run the following command:<\/p>\n
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD<\/span>';<\/pre>\nAgain, make sure you set a strong password for your user. Next, set the appropriate privileges by running:<\/p>\n
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;<\/pre>\nTo exit the MySQL database server, type:<\/p>\n
exit;<\/pre>\n