fjping0606

linux下登录mysql服务器一般都是在命令行手动输入链接信息

[root@localhost ~]# mysql -hlocalhost -uroot -p11111

而在mysql 5.6之后版本这样登录则会有安全提示

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

 

为了避免出现这个提示,也为了不用每次都这样输入用户名、密码,可以使用一个更加安全简单的方法

只需要简单的配置下my.cnf的client节即可,把用户名和密码信息写入到client节中

# The following options will be passed to all MySQL clients  
[client]  
host = "localhost"
user = "root"
password = "11111"
port = 3306
socket = /tmp/mysql.sock
 

 

或者写入到单独的一个文件中,例如/etc/mysql.pwd.cnf,内容:

[mysql]
host = "localhost"
user = "root"
password = "11111"
port = 3306
socket = /tmp/mysql.sock

登录的时候指定此文件登录

[root@localhost ~]# mysql --defaults-file=/etc/mysql.pwd.cnf

或指定某个库登录:

[root@localhost ~]# mysql --defaults-file=/etc/mysql.pwd.cnf  库名

 

分类:

技术点:

相关文章:

  • 2021-08-12
  • 2022-02-07
  • 2022-12-23
  • 2021-06-06
  • 2021-05-24
  • 2021-10-07
  • 2021-10-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-15
  • 2021-06-17
  • 2022-12-23
  • 2021-12-13
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案