免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
mysql問題(musees經(jīng)典) - 問題 the to socket that MySQL you can is You server
Mysql連接錯(cuò)誤:
mysql_real_connetc() failed:
 Error 2002 (Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2))。
這是因?yàn)镸ysql有兩種方式連接:
1、Unix socket方式,-p用localhost關(guān)鍵字,也就是本地連接,速度快
2、TCP/IP方式, -p指定IP地址。
其中第一種方式需要一個(gè)socket文件,文件類型域是“s”,后綴為.sock的連接文件。由于socket文件是在Mysql的數(shù)據(jù)存放目錄下面生成的,當(dāng)我們改變Mysql的數(shù)據(jù)存放地址時(shí),也需要改變socket的存放地址,反應(yīng)在/etc/my.cnf中:
[client]
port=3306
socket   =      /home/mysql_data/mysql/mysql.sock

[mysqld]
datadir=/home/mysql_data/mysql
socket=/home/mysql_data/mysql/mysql.sock

[mysql.server]
user=mysql
basedir=/home/mysql_data

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
這樣服務(wù)器和客戶端都需要指定socket文件,才能在用localhost訪問數(shù)據(jù)庫(kù)時(shí)正確的找到socket文件。
但現(xiàn)在的問題是
在命令行下面可以正常操作;
在C代碼里面不能,所以只好改用IP地址操作。


.2.3 Can‘t connect to [local] MySQL server Error

....

Here are some reasons the Can‘t connect to local MySQL server error might occur:

1: mysqld is not running.

2:You are running on a system that uses MIT-pthreads. If you are runningon a system that doesn‘t have native threads, mysqld uses theMIT-pthreads package. See section 2.2.2 Operating Systems Supported byMySQL. However, not all MIT-pthreads versions support Unix sockets. Ona system without sockets support you must always specify the hostnameexplicitly when connecting to the server. Try using this command tocheck the connection to the server:

shell>; mysqladmin -h `hostname` version

3:Someone has removed the Unix socket that mysqld uses (default`/tmp/mysqld.sock‘). You might have a cron job that removes the MySQLsocket (for example, a job that removes old files from the `/tmp‘directory). You can always run mysqladmin version and check that thesocket mysqladmin is trying to use really exists. The fix in this caseis to change the cron job to not remove `mysqld.sock‘ or to place thesocket somewhere else. See section A.4.5 How to Protect or Change theMySQL Socket File `/tmp/mysql.sock‘.

4: You have started themysqld server with the --socket=/path/to/socket option. If you changethe socket pathname for the server, you must also notify the MySQLclients about the new path. You can do this by providing the socketpath as an argument to the client. See section A.4.5 How to Protect orChange the MySQL Socket File `/tmp/mysql.sock‘.

5: You areusing Linux and one thread has died (core dumped). In this case youmust kill the other mysqld threads (for example, with the mysql_zapscript before you can start a new MySQL server. See section A.4.1 WhatTo Do If MySQL Keeps Crashing.

6: You may not have read andwrite privilege to either the directory that holds the socket file orprivilege to the socket file itself. In this case you have to eitherchange the privilege for the directory / file or restart mysqld so thatit uses a directory that you can access.
If you get the errormessage Can‘t connect to MySQL server on some_hostname, you can try thefollowing things to find out what the problem is :

Check ifthe server is up by doing telnet your-host-name tcp-ip-port-number andpress Enter a couple of times. If there is a MySQL server running onthis port you should get a responses that includes the version numberof the running MySQL server. If you get an error like telnet: Unable toconnect to remote host: Connection refused, then there is no serverrunning on the given port.

Try connecting to the mysqld daemonon the local machine and check the TCP/IP port that mysqld it‘sconfigured to use (variable port) with mysqladmin variables.
Check that your mysqld server is not started with the --skip-networking option.

建議把mysql.sock保護(hù)一下,不然給個(gè)調(diào)皮的luser刪了就麻煩了。

A.4.5 How to Protect or Change the MySQL Socket File `/tmp/mysql.sock‘

Ifyou have problems with the fact that anyone can delete the MySQLcommunication socket `/tmp/mysql.sock‘, you can, on most versions ofUnix, protect your `/tmp‘ filesystem by setting the sticky bit on it.Log in as root and do the following:

shell>; chmod +t /tmp
This will protect your `/tmp‘ filesystem so that files can be deleted only by their owners or the superuser (root).

You can check if the sticky bit is set by executing ls -ld /tmp. If the last permission bit is t, the bit is set.


You can change the place where MySQL uses / puts the socket file the following ways:

Specify the path in a global or local option file. For example, put in /etc/my.cnf:
[client]
socket=path-for-socket-file

[mysqld]
socket=path-for-socket-file
See section 4.1.2 `my.cnf‘ Option Files.
Specifying this on the command-line to safe_mysqld and most clients with the --socket=path-for-socket-file option.
Specify the path to the socket in the MYSQL_UNIX_PORT environment variable.
Definingthe path with the configure option--with-unix-socket-path=path-for-socket-file. See section 2.3.3 Typicalconfigure Options.
You can test that the socket works with this command:

shell>; mysqladmin --socket=/path/to/socket version
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
解決Can't connect to local MySQL server through socket '/tmp/mysql.sock'錯(cuò)誤
mysql啟動(dòng)的四種方式
mysqld_multi管理多個(gè)mysqld的服務(wù)進(jìn)程
LINUX重啟MYSQL的命令
Mysql數(shù)據(jù)庫(kù)學(xué)習(xí)
Can''''t connect to local MySQL server through socket 問題解決
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服