mysql.sock的作用

來源:互聯網
上載者:User

標籤:

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的作用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.