This tutorial intends to teach you to Install and Configure phpMyAdmin on Ubuntu 22.04.
phpMyAdmin is a free web application that provides a convenient GUI for working with the MySQL database management system. It is the most popular MySQL administration tool, used by millions of users worldwide, and has won numerous awards and honors.
With phpMyAdmin, you can do such things as:
- Create and remove users, manage user permissions
- Create, alter, and drop databases, tables, fields, and rows
- Search objects in the entire database or any particular tables
- Import and export data in different formats, including SQL, XML, and CSV
- Monitor processes and track the performance of different queries
- Execute user-defined SQL queries
- Back up your MySQL databases in manual mode
Steps To Install and Configure phpMyAdmin on Ubuntu 22.04
To complete this guide, you need some requirements first.
- log in to your server as a non-root user with sudo privileges and set up a basic ufw firewall. To this, you can check the Initial server setup article for Ubuntu 22.04.
- Install LAMP stack on Ubuntu 22.04. You can visit our article about how to install the LAMP stack on ubuntu 22.04.
When you are done with these requirements you can start to install phpMyAdmin on Ubuntu 22.04.
Create MySQL User for phpMyAdmin
At this point, you need to log in to your MariaDB shell with the command below:
sudo mysql -u root -p
From there, use the command below to create a user, here we named it ‘newuser’:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Grant all the privileges to it:
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
Flush the privileges and exit:
FLUSH PRIVILEGES; Exit;
Install phpMyAdmin on Ubuntu 22.04
Here we will install phpMyAdmin by downloading the zip file from the phpMyadmin Downloads page. Visit the page and check for the latest version and copy the link address of the all languages zip file.
First, use the wget command to download the phpMyAdmin on Ubuntu 22.04:
sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip
Next, you can extract your downloaded file with the command below:
sudo unzip phpMyAdmin-*-all-languages.zip
Here you need to move your extracted files to the /usr/share/phpmyadmin directory:
sudo mv phpMyAdmin-*-all-languages /usr/share/phpmyadmin
Switch the phpMyAdmin directory on Ubuntu 22.04 with the following command:
The sample configuration file for phpMyAdmin already exists in the directory. You just need to rename it with the following command:
sudo mv config.sample.inc.php config.inc.php
Also, you need to generate a secret string for the next steps. To do this, run the following command:
openssl rand -base64 32
In your output, you will see something similar to this:
Configure phpMyAdmin on Ubuntu 22.04
At this point, you need to make some configuration changes to the file that you have renamed before.
Open the file with your favorite text editor, here we use vi editor:
sudo vi config.inc.php
At the file, find the line below and enter the secret string that you have generated before in it:
$cfg['blowfish_secret'] = 'yourgeneratedstring';
Next, find the ‘Directories for saving/loading files from server’ section and add the following line under this section:
$cfg['TempDir'] = '/tmp';
When you are done, save and close the file.
This temp directory that you have defined in the phpMyAdmin configuration file on Ubuntu 22.04, is used to store the cache files.
Now use the following command to create it:
sudo mkdir /usr/share/phpmyadmin/tmp
Then, set the ownership and correct permissions with the commands below:
# sudo chown -R www-data:www-data /usr/share/phpmyadmin # sudo chmod 777 /usr/share/phpmyadmin/tmp
Create Apache configuration file for phpMyAdmin
Here you need to create an Apache configuration file for the phpMyAdmin files on Ubuntu 22.04.
Create and open the file with your favorite text editor, here we use vi:
sudo vi /etc/apache2/conf-available/phpmyadmin.conf
Add the following contents to the file:
Alias /phpmyadmin /usr/share/phpmyadmin <Directory /usr/share/phpmyadmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require all granted </RequireAny> </IfModule> </Directory> <Directory /usr/share/phpmyadmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require all granted </RequireAny> </IfModule> </Directory>
When you are done, save and close the file.
Restart Apache to apply the changes:
# sudo a2enconf phpmyadmin # sudo systemctl restart apache2
Access phpMyAdmin Web Interface
At this point, you can access the phpMyAdmin web interface by typing your server’s IP address in your web browser followed by /phpmyadmin:
You will see the phpMyAdmin login screen. Enter your MariaDB user and password that you have created before and press the Login button to see your phpMyAdmin dashboard.
That’s it, you are done. Enjoy using your phpMyAdmin.
At this point, you have learned to Install and Configure phpMyAdmin on Ubuntu 22.04.
Hope you enjoy it. You may be like these articles too:
How To Install aaPanel on Ubuntu 22.04