Search This Blog

Monday, October 08, 2012

PhpMyAdmin - Access denied for user root@localhost


PhpMyAdmin - Access denied for user root@localhost


In the PHP programming language, there is an open source tool called PhpMyAdmin that handles theadministration of MySQL. Access can be denied when access to MySQL is attempted through theroot 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. 

PhpMyAdmin - Access denied for user root@localhost




Beginners may face problems accessing MySql by the root user. This happens when the root requires you to enter a password and the user has either entered a the wrong one or has not provided one at all. This can be easily configured using the following steps:
  • Step1: Open MySql
  • Step2: 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 your new password for the root user, find the command $cfg['Servers'][$i]['password'] = ''; and enter your password 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 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 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 '

No comments:

Post a Comment

Thank you