How to install phpMyAdmin on Ubuntu?
phpMyAdmin is a free, open-source web-based interface that lets you manage MySQL and MariaDB databases on Ubuntu with ease. Whether you’re a beginner or an experienced database administrator, you can skip the command-line and work through your browser.
In this guide, we’ll show you how to install phpMyAdmin on Ubuntu (tested on Ubuntu 22.04/24.04 LTS) in just a few minutes.
Prerequisites:
- An Ubuntu VPS (with root access or a user with sudo privileges)
- A fully installed LAMP stack (Linux + Apache + MySQL/MariaDB + PHP)
- A web browser to connect to phpMyAdmin
Steps to install phpMyAdmin on Ubuntu Server:
Step 1: Update Your Server
First, update your server’s package list. Run this command:
apt update
Step 2: Install phpMyAdmin and Required PHP Extensions
Now install phpMyAdmin along with some useful PHP extensions that help it work better:
apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
These extensions help with:
-> php-mbstring: Handling special characters and multiple languages.
-> php-zip: Uploading .zip files.
-> php-gd: Image processing features.
-> php-json: Reading and writing JSON data.
-> php-curl: Connecting to other servers.
If you’re using PHP 8.0 or another version, make sure to install version-specific extensions like php8.0-mbstring.
During installation, follow these prompts:
Server Selection: Choose apache2 by pressing space to select, then tab, then enter.
Configure database with dbconfig-common: Select Yes.
Set MySQL password: Enter and confirm a password for the phpmyadmin MySQL user.
Important Note:
If you see a password validation error, it’s likely because the MySQL “Validate Password” plugin is on. You’ll need to disable it temporarily.
To do that:
Open MySQL:
sudo mysql
Or if MySQL needs a password:
mysql -u root -p
Disable Password Validation Plugin:
UNINSTALL COMPONENT "file://component_validate_password";
Then exit:
exit
Try the installation again:
apt install phpmyadmin
Once done, you can re-enable password validation (optional):
sudo mysql
INSTALL COMPONENT "file://component_validate_password";
exit
Step 3: Enable mbstring and Restart Apache
Run:
phpenmod mbstring
systemctl restart apache2
phpMyAdmin is now installed and linked to Apache.
Step 4: Create a New MySQL Admin User for phpMyAdmin
phpMyAdmin lets you manage your MySQL databases through a web interface. Normally, it uses the root MySQL user, but on Ubuntu 20.04 or later, the root user uses a login method (auth_socket) that doesn’t work with phpMyAdmin.
So, you need to create a new MySQL user that can log in with a password.
Steps to Create a phpMyAdmin User
Open the MySQL shell:
sudo mysql
Create a new user with a password:
CREATE USER 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';
Replace yourusername and yourpassword with your own.
Give the user full access to a database:
GRANT ALL PRIVILEGES ON yourdatabase.* TO 'yourusername'@'localhost';
Replace yourdatabase with the name of your database.
Apply the changes:
FLUSH PRIVILEGES;
Exit MySQL:
EXIT;
Step 5: Log In to phpMyAdmin
Open your browser and go to one of these URLs (depending on your setup):
http://localhost/phpmyadmin
http://your-server-ip/phpmyadmin
Enter the username and password you just created, and click Go.
You should now see the phpMyAdmin dashboard, where you can manage your databases.
Conclusion
Installing phpMyAdmin on Ubuntu is simple. Just update your system, install phpMyAdmin using the package manager, and enable it with your web server. Once done, you can manage your MySQL or MariaDB databases easily through a web browser without using terminal commands.