mysql: [Warning] Using a password on the command line interface can be insecure

mysql: [Warning] Using a password on the command line interface can be insecure
解决方法:

登录重新配置的mysql 使用初始化秘密无法连接到mysql:

提示:Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
或者
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)

在输入指令:mysql -uroot -p***** 初始化配置mysql密码时提示上边错误


查看官网文献:

官网:https://dev.mysql.com/doc/refman/8.0/en/password-security-user.html

说明如下:
6.1.2.1 End-User Guidelines for Password Security
MySQL users should use the following guidelines to keep passwords secure.

When you run a client program to connect to the MySQL server, it is inadvisable to specify your password in a way that exposes it to discovery by other users. The methods you can use to specify your password when you run client programs are listed here, along with an assessment of the risks of each method. In short, the safest methods are to have the client program prompt for the password or to specify the password in a properly protected option file.

6.1.2.1最终用户密码安全准则
MySQL用户应遵循以下准则来保护密码安全。

当您运行客户端程序以连接到MySQL服务器时,建议不要以其他人可以发现它的方式指定密码。此处列出了您在运行客户端程序时可以用来指定密码的方法,以及每种方法的风险评估。简而言之,最安全的方法是让客户端程序提示输入密码,或在经过适当保护的选项文件中指定密码。

解决方案:

1.停止mysql服务的运行

[root@hadoop102 mysql-libs]# service mysql stop

2.跳过受权表访问

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3.登录mysql

[root@hadoop102 mysql-libs] mysql -u root mysql
mysql>

4.设置mysql新密码

把空的用户密码都修改成非空的密码

在mysql5.7以下的版本如下:

mysql> UPDATE user SET Password=PASSWORD(‘newpassword’) where USER=‘root’ and host=‘127.0.0.1’ or host=‘localhost’;

在mysql5.7版本如下:

update mysql.user set authentication_string=password(‘newpassword’) where user=‘root’ and host=‘127.0.0.1’ or host=‘localhost’;

mysql> FLUSH PRIVILEGES;
mysql> quit

5.重启mysql 使用新秘密登录 设置的password(‘newpassword’)

[root@hadoop102 mysql-libs]# service mysql stop

使用新秘密登录:

[root@master mysql]# mysql -uroot -p
Enter password: 新设置的秘密
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright © 2000, 2015, 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>

猜你喜欢

转载自blog.csdn.net/qq_42235737/article/details/108429206