22 C
Texas
angeloma
Senior Writer and partner

How to solve the “Access denied for root” error on PhpMyAdmin log in?

In our recent article, we explain how to install the latest PhpMyAdmin on Ubuntu 18.04. We explain the advantages that this may have. For example, with the updates to the program improves its usability and stability. This is important when working with data. However, you may not be able to log in as a root user. That is why in this post I will show you How to solve the “Access denied for root” error on PhpMyAdmin log in?

The “Access denied for root” error on PhpMyAdmin log in

The problem arises because, from version 5.7 of MySQL and MariaDB 10, the root user will only be able to log in if it is executed as superuser. That is, PhpMyAdmin runs through the non-root user of the operating system. Then, from PhpMyAdmin the root user cannot be logged in.

This situation can be very annoying but it has its reason to be. Those of us who administer databases know that it is not recommended to leave the root user enabled. This is because if the root user is compromised, all data will be compromised. The correct security policy is not to allow its use unless you use remote access with strong security policies.

On the other hand, PhpMyAdmin also understands this situation and does not attempt to provide a solution that could compromise server security.

So, what is the solution?

- Advertisement -

The optimal solution is to create a new user with all permissions on the database. With this, you will be able to perform many operations from PhpMyAdmin without any logging problems.

To do this, we need to open a terminal and connect to our MySQL or MariaDB server.

Note that to use the root user in MySQL / MariaDB you must use sudo. If you remove it, it will give the same error as in PhpMyAdmin. That is, the error comes from MySQL / MariaDB.

:~$ mysql -u root -p
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

So, you have to use sudo or to be the system root user.

:~$ sudo mysql -u root -p

Next, create the new user.

>CREATE USER 'new_user'@'%' IDENTIFIED BY 'your-password';

Note: The % sign means that the new user will be able to connect to the MySQL / MariaDB server from any IP.

Then assign the permissions to this new user.

> GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'%' WITH GRANT OPTION;

1.- Fixing the error on the phpmyadmin log in
1.- Fixing the error on the phpmyadmin login

Now open your PHPMyAdmin and you should be able to log in with your new user.

2.- Phpmyadmin log in
2.- Phpmyadmin log in

3.- Phpmyadmin working
3.- Phpmyadmin working

So, for security reasons PhpMyAdmin cannot log in as root user, however to solve the situation you can create another user with similar permissions.

Conclusion

In this post, you have learned to solve The “Access denied for root” error on PhpMyAdmin log in. This way you will be able to enjoy this great MySQL / MariaDB administration program.

You can also read: How to reset the MySQL / MariaDB root password?

Please share this post with your friends.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

4 COMMENTS

  1. I created a user joker@’%’ and config Require all grant (Require IP too in other moment) in file configuration phpmyadmin. I failed with login with phpmyadmin, however I can login into terminal…

  2. Very useful. It’s horrible when you’ve set everything up meticulously and at the last moment you can’t log in. Great to have a clear solution like yours.

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article