大网数据广告活动
服务器运维问答

MySQL root user with no password (on local dev) stopped permitting access after update

· 52CE 我爱测

I have MySQL running on a virtual machine on my laptop within a host only network (no access to the wider internet except when I turn on the NAT interface to update the O/S). For convenience, I have the root user with no password…

问题原文

原帖链接 · Ben Holness · CC BY-SA 3.0

I have MySQL running on a virtual machine on my laptop within a host only network (no access to the wider internet except when I turn on the NAT interface to update the O/S). For convenience, I have the root user with no password. I have a number of projects that are setup to access the database this way within my development environment.

I just did an apt-get upgrade, which included updating MySQL to 5.7.18 (I am running Ubuntu 16.04.2 LTS) and now all of my projects are getting access denied. I am not sure which version MySQL was at before the update.

From the console, I can mysql --user=root with no problems if I am logged in as root, but not if I am logged in as anyone else.

Can anyone help determine what the update changed and how I can configure MySQL to allow root user access with no password again?

已采纳解答

原帖链接 · Ben Holness · CC BY-SA 3.0

I'm not sure if the update changed the plugin for root@localhost or if the plugin remained unchanged and MySQL's behavior changed, but I resolved this problem by changing the plugin for root@localhost to mysql_native_password with the following SQL:

UPDATE user SET plugin='mysql_native_password' WHERE user='root' AND host='localhost';
FLUSH PRIVILEGES;

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。