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

Is it normal that one can access MySQL as root without entering password, although password is set?

· 52CE 我爱测

I just installed MySQL (Ver 14.14 Distrib 5.7.22) on Ubuntu 18.04 and I discovered something weird: I installed MySQL and used mysql_secure_installation to set a password for root, but as soon as I am logged in SSH with any user …

问题原文

原帖链接 · xinxin · CC BY-SA 4.0

I just installed MySQL (Ver 14.14 Distrib 5.7.22) on Ubuntu 18.04 and I discovered something weird:

I installed MySQL and used mysql_secure_installation to set a password for root, but as soon as I am logged in SSH with any user with sudo-rights, I can simply access MySQL without being prompted to enter a password via mysql -u root or via mysql -u root -p & simply clicking ENTER (when asked "Enter password:").

Is this normal?

I know from prior versions that I always had to enter a password when I wanted to access MySQL, even with sudo.

已采纳解答

原帖链接 · johannes · CC BY-SA 4.0

Ubuntu's MySQL packages (which are based on Debian's) use by default the auth_socket plugin. With this plugin when connecting from the local machine no password is required, but the server identifies the operating system user and matches that user. So if you are root on the system and login you become root. This avoids having to setup a MySQL root password first.

See also https://wiki.debian.org/MySql

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

资料来源与适用范围

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

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

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