Access denied for user 'root'@'localhost' after installing phpmyadmin on ubuntu
This error can be fixed, the following command will reconfigure your phpMyAdmin credentials to gain access to the MYSQL DB:
sudo dpkg-reconfigure phpmyadmin
/!\ This will provide few interactive menus that will allow you to reconfigure the phpMyAdmin package with NEW credentials /!\
But you could also reconfigure it manually :
1 - Log into mysql as root
mysql -u root -p
2 - Make sure 'phpmyadmin' user exists :
SELECT User FROM mysql.user;
3 - Switch to the appropriate MYSQL DB :
use phpmyadmin;
4 - Set new password for the phpmyadmin user
UPDATE user SET password=PASSWORD('yourNewPassword') WHERE User='phpmyadmin';
MySQL Error: : 'Access denied for user 'root'@'localhost'
- Open and edit
/etc/my.cnf
or/etc/mysql/my.cnf
, depending on your distribution. - Add
skip-grant-tables
under[mysqld]
- Restart MySQL
- You should be able to log in to MySQL now using the below command
mysql -u root -p
- Run
mysql> flush privileges;
- Set new password by
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
- Go back to /etc/my.cnf and remove/comment skip-grant-tables
- Restart MySQL
- Now you will be able to login with the new password
mysql -u root -p
Access denied for user 'root'@'localhost' with PHPMyAdmin
Edit your phpmyadmin config.inc.php file and if you have Password, insert that in front of Password in following code:
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = '**your-root-username**';
$cfg['Servers'][$i]['password'] = '**root-password**';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
phpMyAdmin access denied
try this in your phpmyadmin config.inc.php :-
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Related Topics
How to Get Rid of MySQL Error 'Prepared Statement Needs to Be Re-Prepared'
Least Memory Intensive Way to Read a File in PHP
Upload a File Using File_Get_Contents
Laravel Socialite: Invalidstateexception
Deleting All Files from a Folder Using PHP
Best Practice to Generate Random Token for Forgot Password
Using Strtotime for Dates Before 1970
How to Implement Pagination in PHP
Undefined Variable Problem with PHP Function
Binding Parameters for Where in Clause with Pdo
Get Custom Product Attributes in Woocommerce
Echo a Multidimensional Array in PHP