linux系统的数据库是本地吗,Linux下MySQL无法在本地以非root用户身份连接数据库...
標題有點羅嗦,目前出現的問題如下:
當以非root身份登錄數據庫時,會報錯
mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
而使用root身份訪問就沒有問題
問題探究
查看root用戶使用的認證插件:
mysql> select user,plugin from user where user = 'root';
+------+-------------+
| user | plugin |
+------+-------------+
| root | auth_socket |
+------+-------------+
1 row in set (0.00 sec)
MySQL使用的auth_socket是通過Unix套接字進行連接認證[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]
因此可以將認證插件改為 mysql_native_password
解決方法
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
FLUSH PRIVILEGES;
另請參閱
[1] https://dev.mysql.com/doc/refman/8.0/en/socket-pluggable-authentication.html
[2] https://mariadb.com/kb/en/authentication-plugin-unix-socket/
標簽:socket,plugin,mysql,Linux,以非,user,MySQL,password,root
來源: https://www.cnblogs.com/ZanyRain/p/12243460.html
總結
以上是生活随笔為你收集整理的linux系统的数据库是本地吗,Linux下MySQL无法在本地以非root用户身份连接数据库...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 面向dba的linux shell 脚本
- 下一篇: navicat使用查询向表中插入一行记录