標籤:
1、在編譯安裝mysql的時候,會將mysql的設定檔複製到/etc/my.conf中:
[[email protected] mysql]# cp support-files/my-small.cnf /etc/my.cnf 將配置模板複製到mysql的設定檔cp:是否覆蓋"/etc/my.cnf"? y
2、可以通過查看/etc/my.conf查看mysql.sock的目錄位置:
[[email protected] ~]# cat /etc/my.cnf [mysqld]port = 3306socket = /tmp/mysql.sockskip-external-lockingkey_buffer_size = 16Kmax_allowed_packet = 1Mtable_open_cache = 4sort_buffer_size = 64Kread_buffer_size = 256Kread_rnd_buffer_size = 256Knet_buffer_length = 2Kthread_stack = 128K
3、在登入mysql的時候可以加上mysql.sock:
[[email protected] ~]# mysql -u root -poldboy123 -S /tmp/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.5.32 MySQL Community Server (GPL)Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
以下內容為轉載:http://jimingsong.iteye.com/blog/1418638
Mysql有兩種串連方式:
(1),TCP/IP
(2),socket
對mysql.sock來說,其作用是程式與mysqlserver處於同一台機器,發起本地串連時可用。
例如你無須定義串連host的具體IP地址,只要為空白或localhost就可以。
在此種情況下,即使你改變mysql的外部port也是一樣可能正常串連。
因為你在my.ini中或my.cnf中改變連接埠後,mysql.sock是隨每一次 mysql server啟動產生的。已經根據你在更改完my.cnf後重啟mysql時重建了一次,資訊已跟著變更。
那麼對於外部串連,必須是要變更port才能串連的。
linux下安裝mysql串連的時候經常回提示說找不到mysql.sock檔案,解決辦法很簡單:
如果是新安裝的mysql,提示找不到檔案,就搜尋下,指定正確的位置。
如果mysql.sock檔案誤刪的話,就需要重啟mysql服務,如果重啟成功的話會在datadir目錄下面產生mysql.sock 到時候指定即可。
如果還不行就選擇用TCP串連方式串連就行了,其實windows下還支援管道串連方式。
mysql.sock的作用