How do I fix phpMyAdmin access denied in Ubuntu?

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.

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
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.


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.


  1. Julian

    Excellent!! Very useful

  2. Vinicius

    I created a user [email protected]’%’ 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…

  3. George

    thanks a lot – appreciate!

  4. Steve

    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.

    In PHP programming language there is an open source tool called PhpMyAdmin that handles the administration of MySQL. Access can be denied when access to MySQL is attempted through the root user. Root requires insertion of a password and once that is wrongly entered or is not provided, this issue arises. This can be configured with the help of the PHP tool. The rights of the root user can also be reset at the same time.



    Beginners may face problems accessing MySql by the root. This happens when it requires you to enter a password and the user has either entered the wrong one or has not provided one at all. This can be easily configured using the following steps:

    • Step 1: Open MySql.
    • Step 2: Through phpMyAdmin/librarires, you should edit

      • Where $cfg['PmaAbsoluteUri'] = ''; is displayed, alter the command to $cfg['PmaAbsoluteUri'] = 'localhost/phpmyadmin/';

    • Step 3: Concerning the server commands, change $cfg['Servers'][$i]['host'] = 'localhost'; to $cfg['Servers'][$i]['host'] = 'Localhost';

    • Step 4: To enter root user's new password, find the command $cfg['Servers'][$i]['password'] = ''; and enter it in the field provided.
      • For example: $cfg['Servers'][$i]['password'] = 'type your password here';
    • Step 5: Reboot MySql

    To reset the rights of the root user

    To be able to reset the root rights, you should enter the following commands:

    mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost  IDENTIFIED BY ' your current password ' WITH GRANT   

    Insert the host and password

    This section will allow to insert the host's name and user account by default and set them up with the correct password, as allocated to them in the php.ini folder. To do so, use the code below:

    • Default host for mysql_connect() (doesn't apply in safe mode):
      • mysqli.default_host ='localhost'    
    • Default user for mysql_connect() (doesn't apply in safe mode):
      • mysqli.default_user ='root'    
    • Default password for mysqli_connect() (doesn't apply in safe mode):
      • Note: It is generally a bad idea to store passwords in this file as any user with PHP access can view it

      • mysqli.default_pw =' your current password '</ital>

    For more help with error codes, check out our forum!

    Subject Replies

    Selfie video verification upload error 129

    Error unable to complete request 46

    Diskette Drive 0 seek failure (error message) 133

    Yahoo managed email 19

    EXPLORER.EXE corrupted or infected 50

    i cant log in to tik tok 48

    How to fix Windows error message "error:0x80300001" 35

    regedit is disabled by the administrator 89

    Counter Strike fatal error 36

    Removing write protection using Diskpart 13

    PHPmyadmin access denied: for user 'root'@'localhost'

    Contents Introduction Reset the rights of the root user Insert the host and password Introduction Beginners may face problems accessing MySql by the root. This happens when it requires you to enter a password and the user has...

    How do I fix phpMyAdmin Access Denied?

    How to fix an error of PhpMyAdmin access denied in xamp mySql..
    So , you have to open XAMPP Control Panel ->Click MySql Config->Click my.ini. ... .
    You have to write this line skip-grant-tables after [mysqld]..
    Open xamp folder ->PhpMyAdmin .You will see file in phpMyAdmin folder, just open it with notepad++.

    How do I access phpMyAdmin from browser in Ubuntu?

    Access phpMyAdmin on a Browser In case you use localhost, use the http://localhost/phpmyadmin URL. Due to security issues, Ubuntu 18.04 and Ubuntu 20.04 don't support root login. Instead, log in with the phpmyadmin username and the MySQL password you set during Step 1.

    How do I allow access to phpMyAdmin?

    Refer below steps to enable remote connection to a MySQL database on phpMyAdmin.
    Login ACP..
    Access phpMyAdmin..
    Go to User Accounts..
    Select the Username and click on Edit Privileges..
    Click on Login Information..
    On Hostname Select “Any Host” and click Go..

    How do I fix phpMyAdmin 404 not found Ubuntu?

    Fix for PhpMyAdmin Not found (404 Error) – Apache Ubuntu.
    Check the location of apache.conf file. ... .
    Open this 'apache2.conf' file with any editor and include phpmyadmn configuration file path under it. ... .
    Include phpmyadmn configuration file path at the bottom of this file..