MySQL 5.7 and above
Since October 2015,
root now requires sudo privileges in MySQL 5.7+ and phpMyAdmin will not be able to use root credentials.
It’s also not recommended that you allow the root account to be accessible remotely via phpMyAdmin as bots and hackers scan for these accounts continuously.
Instead, create a new superuser account with a different username.
Create User for phpMyAdmin
In terminal, log in to MySQL as
root. You may have created a root password when you installed MySQL for the first time or the password could be blank, in which case you can just press
ENTER when prompted for a password. If you have forgotten your root password, you can always Reset the MySQL Root Password.
sudo mysql -p -u root
Now add a new MySQL user with the username of your choice. In this example we are calling it
pmauser (for phpmyadmin user). Make sure to replace
password_here with your own. You can generate a password here.
% symbol here tells MySQL to allow this user to log in from anywhere remotely. If you wanted heightened security, you could replace this with an IP address.
CREATE USER 'pmauser'@'%' IDENTIFIED BY 'password_here';
Now we will grant superuser privilege to our new user.
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;
You should now be able to access phpMyAdmin using this new user account.
Hope this helps! 😀
MySQL 5.6 and below
If you have forgotten your root password, you can try reset it via command line.
You could also create a new user for phpMyAdmin by following the step for MySQL 5.7 and above (the commands are the same).
While you’re here, you may be interested in an article I wrote on manually upgrading phpMyAdmin. Since the release of Ubuntu 18.04, the repositories have been slow to update with the latest version of phpMyAdmin causing some compatibility issues, so make sure you have the latest version:
Are you backing up your MySQL databases? I’ve written a detailed guide on how to automatically dump and archive databases using
p.s. I increased my AdSense revenue by 68% using AI 🤖. Read my Ezoic review to find out how.