啟動MYSQL提示:Can’t connect to MySQL through socket ‘/tmp/mysql.sock’

來源:互聯網
上載者:User

啟動MYSQL是出現以下錯誤:

[root@www ~]# /usr/local/webserver/mysql/bin/mysqladmin -u root -p 12345678
Enter password:
/usr/local/webserver/mysql/bin/mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (111)’
Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists!

解決方案:

 代碼如下 複製代碼

[root@www ~]# /usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.1.38-log Source distribution

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

mysql>

mysql的參數說明:

/usr/local/webserver/mysql/bin/mysql –help | less

列舉常用參數:

-u, –user=name     User for login if not current user.
-p, –password[=name]
                      Password to use when connecting to server. If password is
                      not given it’s asked from the tty.
-S, –socket=name   Socket file to use for connection.


另一種解決辦法


我通過vim /etc/my.cnf,修改了[mysqld]選項下面的socket的值

 代碼如下 複製代碼
socket=/var/lib/mysql/mysql.sock

ok,mysqld可以啟動了

接下來,是mysql啟動不了,同樣,vim /etc/my.cnf,添加了如下指令碼:

[mysql]

 代碼如下 複製代碼
socket=/var/lib/mysql/mysql.sock

然後,mysqladmin啟動不了,還是一樣,在[mysqladmin]下面socket值設定為同樣的路徑
ok,可以啟動了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.