It is usually recommended to use distribution packages when possible - they usually provide integration to your distribution and you will automatically get security updates from your distribution.
You can find a collection of step by step tutorials on how to do that here:
However in some cases if you have a custom environment or if the distribution packages do not work for any reason, you might want to install phpMyAdmin manually.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
There are a few ways of installing phpMyAdmin as described in the official documentation here:
https://docs.phpmyadmin.net/en/latest/setup.html
However I’ve been using another method which is a bit more convenient for some cases, so I’ve decided to put a short tutorial on how to do that!
Prerequisites
Before you get started with this guide, you need to have some basic steps completed.
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04
https://digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04
Step 1 - Install the additional PHP modules
Make sure that you have the additional PHP modules required by phpMyAdmin installed:
Also, you need to do is explicitly enable the mbstring PHP extension, which you can do by typing:
Afterward, restart Apache for your changes to be recognized:
Step 2 - Download the source files
You can visit the following link and copy the link of the latest stable phpMyAdmin version:
https://www.phpmyadmin.net/files/
As of the time of writing this post, the latest phpMyAdmin was 5.0.2. So in order to download the files, you need to run the following commands:
Note: if you don’t have
upzip
already installed you can install it with:After that unzip the archive:
Note: change the
/var/www/html
path in case that you are using a custom virtual host with a non-standard document rootStep 3 - Configure phpMyadmin
First you need to go to the
/var/www/html/phpmyadmin
directory and then update your phpMyAdmin config:Then with your favorite text editor open the
config.sample.inc.php
file:And then update the following line to the correct database host, as we are running MySQL on the same Droplet just put
localhost
:Finally, rename the config:
Finally, in order to log in to phpMyAdmin as your root MySQL user, you will need to switch its authentication method from auth_socket to mysql_native_password if you haven’t already done so. To do this, open up the MySQL prompt from your terminal:
To configure the root account to authenticate with a password, run the following ALTER USER command. Be sure to change password to a strong password of your choosing:
Then, run FLUSH PRIVILEGES which tells the server to reload the grant tables and put your new changes into effect:
After that you should be able to visit http://your_domain_or_IP/phpmyadmin and login with your root user.
Alternatively, some may find that it better suits their workflow to connect to phpMyAdmin with a dedicated MySQL user rather than the root user. To do this, open up the MySQL shell once again:
From there, create a new user and give it a strong password:
Then, grant your new user appropriate privileges. For example, you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command:
After that, you would be able to use the new user to login via phpMyAdmin and manage your databases.
Step 4 - Securing your phpMyAdmin Instance
It is strongly recommended to configure .htaccess authentication in order to protect your phpMyAdmin instance from brute-force attacks and just as a second layer of security.
Edit the linked file that has been placed in your Apache configuration directory:
Add an
AllowOverride All
directive within the<Directory /var/www/html/phpmyadmin>
section of the configuration file, like this:Now that you have enabled .htaccess use for your application, you need to create one to actually implement some security.
Within this file, enter the following information:
You can now create this file and pass it an initial user with the
htpasswd
utility:Now, when you access your phpMyAdmin subdirectory, you will be prompted for the additional account name and password that you just configured.
Conclusion
You have successfully manually installed phpMyAdmin and you should now have phpMyAdmin configured and ready to use on your Ubuntu server.
Hope that this helps! Regards, Bobby