PhpMyAdmin - Access denied for user root@localhost
Beginners may face the problem of accessing MySql by the root user. This issue happens when the root requires you to insert a password and the user has either entered a wrong password or has not provided any. This can be easily configured by the following steps:
- Step1: Open MySql
- Step2: Through the phpMyAdmin/librarires, you should edit the config.inc.php. where it is displayed $cfg['PmaAbsoluteUri'] = ''; alter the command to $cfg['PmaAbsoluteUri'] = 'localhost/phpmyadmin/';
- Step 3: Concerning the server commands, edit $cfg['Servers'][$i]['host'] = 'localhost'; and alter it to $cfg['Servers'][$i]['host'] = 'Localhost';
- Step 4: To enter your new password for the root user, choose the command $cfg['Servers'][$i]['password'] = ''; and enter your password in between the fields provided.
For example:
$cfg['Servers'][$i]['password'] = 'type your password here';
- Step 5: After this procedure, do not forget to reboot MySql
To reset the rights of the root user
To be able to reset the rights of the root user, 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 you to insert the host's name and user account by default and set them with the correct password 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 that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysqli.default_pw =' your current password '