Linux下每次用mysql连接连接服务器,常常用如下方式:

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

每次都输入用户名,密码,多折腾人啊,有没有更方便的方式?

我们只需要简单地配置下my.cnf的client节即可,把用户名,密码信息都放到client节中。配置示例如下:

  1. # The following options will be passed to all MySQL clients  
  2. 18 [client]  
  3. 19 host = "localhost"                                                                                                                
  4. 20 password    = "11111"  
  5. 21 user = "root"   
  6. 22 port        = 3306  
  7. 23 socket      = /tmp/mysql.sock  

修改my.cnf之后,不需要重启服务器,直接运行mysql,即可方便地连接到指定服务器。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-11
  • 2021-11-04
  • 2022-01-30
猜你喜欢
  • 2021-06-14
  • 2021-12-08
  • 2021-06-25
  • 2021-11-21
  • 2021-12-13
  • 2022-02-07
  • 2022-12-23
相关资源
相似解决方案