linux系统的数据库是本地吗,Linux下MySQL无法在本地以非root用户身份连接数据库...
標(biāo)題有點(diǎn)羅嗦,目前出現(xiàn)的問(wèn)題如下:
當(dāng)以非root身份登錄數(shù)據(jù)庫(kù)時(shí),會(huì)報(bào)錯(cuò)
mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
而使用root身份訪問(wèn)就沒(méi)有問(wèn)題
問(wèn)題探究
查看root用戶使用的認(rèn)證插件:
mysql> select user,plugin from user where user = 'root';
+------+-------------+
| user | plugin |
+------+-------------+
| root | auth_socket |
+------+-------------+
1 row in set (0.00 sec)
MySQL使用的auth_socket是通過(guò)Unix套接字進(jìn)行連接認(rèn)證[1]
The unix_socket authentication plugin works by calling the getsockopt system call with the SO_PEERCRED socket option, which allows it to retrieve the uid of the process that is connected to the socket. It is then able to get the user name associated with that uid. Once it has the user name, it will authenticate the connecting user as the MariaDB account that has the same user name. [2]
因此可以將認(rèn)證插件改為 mysql_native_password
解決方法
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
FLUSH PRIVILEGES;
另請(qǐng)參閱
[1] https://dev.mysql.com/doc/refman/8.0/en/socket-pluggable-authentication.html
[2] https://mariadb.com/kb/en/authentication-plugin-unix-socket/
標(biāo)簽:socket,plugin,mysql,Linux,以非,user,MySQL,password,root
來(lái)源: https://www.cnblogs.com/ZanyRain/p/12243460.html
總結(jié)
以上是生活随笔為你收集整理的linux系统的数据库是本地吗,Linux下MySQL无法在本地以非root用户身份连接数据库...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 面向dba的linux shell 脚本
- 下一篇: linux lw3m多行文本使用,lin