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

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

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.

Introduction

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 config.inc.php.

    • 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!