在ubuntu上安装phpmyadmin后,拒绝用户'root'@'localhost'的访问 [英] Access denied for user 'root'@'localhost' after installing phpmyadmin on ubuntu
问题描述
我按照以下步骤在ubuntu服务器上安装了phpmyadmin:
I installed phpmyadmin on my ubuntu server following these steps here:
https://www.rosehosting.com/blog/install-phpmyadmin-on-ubuntu-16-04/
我按照以下步骤安装了apache,php,mysql:
I installed apache, php, mysql following these steps:
,当我登录到 http://myserver.com/phpmyadmin 时,出现此错误:
and when I goto login to http://myserver.com/phpmyadmin I get this error:
mysqli_real_connect():(HY000/1045):拒绝用户访问 'root'@'localhost'(使用密码:是)
mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
我做错了什么?我是否错过了上面链接中没有的步骤?
What am I doing wrong? Am I missing a step that is not in the links above?
我已经尝试过了:
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
$ service mysql restart
还有这个
mysql -u root -p
use mysql;
update user set plugin="" where user='root';
flush privilege;
推荐答案
此错误可以得到解决,以下命令将重新配置您的phpMyAdmin凭据以访问MYSQL DB:
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-以root身份登录mysql
1 - Log into mysql as root
mysql -u root -p
2-确保'phpmyadmin'用户存在:
2 - Make sure 'phpmyadmin' user exists :
SELECT User FROM mysql.user;
3-切换到相应的MYSQL DB:
3 - Switch to the appropriate MYSQL DB :
use phpmyadmin;
4-为phpmyadmin用户设置新密码
4 - Set new password for the phpmyadmin user
UPDATE user SET password=PASSWORD('yourNewPassword') WHERE User='phpmyadmin';
这篇关于在ubuntu上安装phpmyadmin后,拒绝用户'root'@'localhost'的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!