1. Home
  2. Linux
  3. Set up phpmyadmin on ubuntu server

Set up PhpMyAdmin on Ubuntu Server

Managing MySQL databases through the command line can be challenging and time-consuming, especially for those without extensive technical knowledge. Fortunately, there is a more user-friendly alternative. That alternative is PhpMyAdmin, and it makes managing MySQL databases on Ubuntu Server much easier. Here’s how to get PhpMyAdmin working on your Ubuntu system.

xr:d:DAFds8YL9ik:2,j:43601822907,t:23032003

Setting up MySQL and Apache on Ubuntu Server

PhpMyAdmin runs with the help of MySQL and Apache. You’ll need to set up both of these tools to get it working on your Ubuntu Server system. Open up a terminal on your Ubuntu Server via SSH (or physically), then use the apt update command to check for software updates.

sudo apt update

After checking for software updates, you will need to install them. Keeping your Ubuntu Server up to date will ensure that PhpMyAdmin runs correctly. To install the updates, use the apt upgrade command.

sudo apt upgrade

Once everything is up to date, you can install the Apache, PHP, and MySQL server packages. The installation process for these packages shouldn’t take long.

sudo apt install apache2 php libapache2-mod-php mysql-server

When the packages are installed on your Ubuntu Server system, you will need to perform the MySQL secure installation. This step is crucial because it allows you to configure a root MySQL password, among other things.

sudo mysql_secure_installation

After you enter the command above, you will see a message from the MySQL server configuration tool. The message is as follows:

Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Please set the password for root here.

Once you have read the message printed by MySQL on the screen, set your root MySQL password. This password must be secure yet memorable. If you have difficulty generating a secure and memorable password, use the Bitwarden password generator.

Once you’ve configured the root MySQL password, PhpMyAdmin is ready to be installed. Continue with the guide in the next section to get the app set up.

How to Install PhpMyAdmin on Ubuntu

PhpMyAdmin can be installed on Ubuntu Server using the included software repositories. This means that there is no need to add any external PPAs, software repositories, or DEB packages.

To set up PhpMyAdmin on your Ubuntu system, use the following apt install command to install the “phpmyadmin” package:

sudo apt install phpmyadmin

After running the command above, you will see the following message on the screen: “The phpmyadmin package must have a database installed and configured before it can be used. This can be optionally handled with dbconfig-common.”

Select “Yes” to configure your PhpMyAdmin installation on Ubuntu with Dbconfig-common.

After selecting “Yes,” you will need to enter a new SQL password for the “phpmyadmin” user account. This password must be secure, or the configuration will fail. Use the Bitwarden password generation tool to create a new password.

Once you have set up your SQL password for PhpMyAdmin, you’ll need to select the correct web server to use with PhpMyAdmin. Select “apache2,” then select “OK” to continue.

Lastly, set up PhpMyAdmin in Apache with the following symlink command.

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

How to Fix SQL Password Errors

If MySQL refuses to accept the password you have set, you can fix this issue with PhpMyAdmin by doing the following:

First, select “abort” in the error message. Then, log into MySQL using the following command:

sudo mysql -p

After logging in, enter the following SQL commands:

UNINSTALL COMPONENT "file://component_validate_password";

exit;

Once the two commands are entered, run the two apt commands below to purge and reinstall PhpMyAdmin:

sudo apt remove --purge phpmyadmin -y
sudo apt install phpmyadmin

You can then use the UI to add an SQL password. When done, log back into SQL:

sudo mysql -p

Enter the two SQL commands below to finish up:

INSTALL COMPONENT "file://component_validate_password";

exit;

When you have entered the last two SQL commands, PhpMyAdmin should be fixed.

Logging into PhpMyAdmin

To access PhpMyAdmin in Ubuntu Server, open a web browser on a device connected to the same network as your server. Then, type the following URL into the address bar:

http://your-server-ip-or-hostname/phpmyadmin

After that, fill in the “phpmyadmin” username and the password you created during the setup process. Once you’re logged in, you’ll have full access to PhpMyAdmin and can use it to manage your databases on Ubuntu Server through the web browser.