MySQL不要显示密码警告

转载:http://www.javashuo.com/article/p-zvosfzqt-ha.htmlmysql

问题显示

[root@localhost ~]# mysql -uroot -p1234567
mysql: [Warning] Using a password on the command line interface can be insecure.sql

解决方法

方法一

一、将密码写入到主配置文件中vim

[root@localhost ~]# vim /etc/my.cnf
[mysqldump]
user=root
password=1234567ide

[mysql]
user=root
password=1234567
二、直接使用命令登陆,再也无需输入帐号密码blog

[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.18-log Source distribution
Copyright (c) 2000, 2017, 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> get

方法二

一、自动配置MYSQL密文密码
该操做会在用户家目录下生成一个隐藏文件".mylogin.cnf",里面记录了MYSQL的密文的密码,只要配置了之后,咱们也是直接使用命令登陆,再也无需输入帐号密码了,若是你想取消,删除此文件便可。
[root@localhost ~]# mysql_config_editor set --user=root --host=localhost --port=3306 --password
Enter password: 输入密码
二、直接使用命令登陆,再也无需输入帐号密码input

[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.18-log Source distribution
Copyright (c) 2000, 2017, 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> it

方法三

一、直接使用命令登陆,屏蔽错误信息io

因为告警信息是标准错误,咱们能够将标准错误的输出信息输出为空。
[root@localhost ~]# mysql -uroot -p1234567 2>/dev/null
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.7.18-log Source distribution
Copyright (c) 2000, 2017, 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>class

相关文章
相关标签/搜索