mysql在登录时的提示甚至不提供密码,如果提供了像mysql -u root -p一样的提示输入密码,如果提供了像mysql -u root这样的提示,则在不询问密码的情况下登录,我已经运行了查询
select user,hosts from mysql.user; 并了解到有3个root用户具有不同的主机,如下所示
+------+-------------+
| user | host |
+------+-------------+
| root | 127.0.0.1 |
| root | db-busindia |
| root | localhost |
+------+-------------+有趣的是mysql服务器名也是db-busindia,root@'db-busindia'是罪魁祸首吗?
发布于 2013-10-26 16:49:05
检查my.cnf文件的客户机节中的行:
user=root
password=some text.这使您可以在没有用户名或密码的情况下登录。如果希望系统提示您输入密码,请删除password行。
发布于 2020-02-27 20:35:57
是的,就连我也很久以前就遇到过这个问题。我们通常会在安装MySQL服务器时遇到它们,所有的客户端连接都是使用套接字建立连接的。您可以简单地在mysql.user表中查看它的插件。
Ubuntu@localhost:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT User, Host, plugin FROM mysql.user;
+------------------+-----------+-----------------------+
| User | Host | plugin |
+------------------+-----------+-----------------------+
| root | localhost | auth_socket |
| mysql.session | localhost | mysql_native_password |
| mysql.sys | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
mysql> update mysql.user set plugin='mysql_native_password' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0您可以通过将插件值更新为“mysql_native_password”来禁用该选项。
Ubuntu@localhost:~# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Ubuntu@localhost:~# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)发布于 2013-11-26 20:09:07
MySQL允许我们在不传递user和password的情况下登录,只需将user和password放入my.cnf即可。
$ mysql请检查通常在/etc/mysql/中的my.cnf,或者如果您有覆盖,您可以在~/.my.cnf中找到它。只要删除user和password即可。
可以看到类似下面这样的内容:
user=root
password=35620fhgf8025ec31ffd2c1
host=127.0.0.1https://stackoverflow.com/questions/19604324
复制相似问题