Linux下連接mysql數據庫
1.[root@localhost ~]# mysql -hlocalhost -uroot -p11111
配置~/.my.cnf的好處
1)不用每次輸入用戶名,密碼
2)避免在shell腳本中出現賬號和密碼
我們可以配置~/.my.cnf的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,即可方便地連接到指定服務器。
ysq原文鏈接:http://www.linuxidc.com/Linux/2012-05/60238.htm