【MySQL】关于 mysql.sock

【MySQL】关于 mysql.sock,第1张

mysql.sock是MySQL的主机和客户机在同一host上的时候,使用unix domain socket做为通讯协议的载体,它比tcp快。

MySQL有两种连接方式: 

(1)TCP/IP 

(2)socket 

其实windows下还支持管道连接方式。

对mysql.sock来说,其作用是程序与MySQLserver处于同一台机器,发起本地连接时可用。 

例如你无须定义连接host的具体IP,只要为空或localhost就可以。 

在此种情况下,即使你改变MySQL的外部port也是一样可能正常连接。 

因为你在my.ini中或my.cnf中改变端口后,mysql.sock是随每一次 mysql server启动生成的,经根据你在更改完my.cnf后重启mysql时重新生成了一次,信息已跟着变更。

那么对于外部连接,必须是要变更port才能连接的。

# systemctl status mysqld

# mysql  --help

mysql.sock 文件解析

https://segmentfault.com/a/1190000016098820

https://blog.csdn.net/kerwin612/article/details/8568206

mysql.sock文件作用

https://www.jianshu.com/p/d6c1e3458ca9

How to Protect or Change the MySQL Unix Socket File

https://dev.mysql.com/doc/refman/8.0/en/problems-with-mysql-sock.html

Missing mysqld.sock file?

https://mariadb.com/kb/en/library/missing-mysqldsock-file/

How to solve “Can't connect to local MySQL server through socket” error?

https://dba.stackexchange.com/questions/98467/how-to-solve-cant-connect-to-local-mysql-server-through-socket-error

https://dba.stackexchange.com/questions/11027/cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-sock

不存在mysql.sock丢失这一说法。mysql默认是在/tmp/mysql.sock,你可以修改my.cnf把他改在别的路径,注意权限。另外只有localhost和127.0.0.1是连接sock的,ip连接是通过ip和端口连接mysql的。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6150766.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-16
下一篇 2023-03-16

发表评论

登录后才能评论

评论列表(0条)

保存