mysql.sock.lock的作用_mysql.sock的作用

1、在编译安装mysql的时候,会将mysql的配置文件复制到/etc/my.conf中:

[root@Web-lnmp02 mysql]# cp support-files/my-small.cnf /etc/my.cnf 将配置模板复制到mysql的配置文件

cp:是否覆盖"/etc/my.cnf"? y

2、可以通过查看/etc/my.conf查看mysql.sock的目录位置:

48304ba5e6f9fe08f3fa1abda7d326ab.png

[root@mysql ~]# cat /etc/my.cnf

[mysqld]

port = 3306

socket = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16K

max_allowed_packet = 1M

table_open_cache = 4

sort_buffer_size = 64K

read_buffer_size = 256K

read_rnd_buffer_size = 256K

net_buffer_length = 2K

thread_stack = 128K

48304ba5e6f9fe08f3fa1abda7d326ab.png

3、在登录mysql的时候可以加上mysql.sock:

48304ba5e6f9fe08f3fa1abda7d326ab.png

[root@mysql ~]# mysql -u root -poldboy123 -S /tmp/mysql.sock

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server 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 its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

48304ba5e6f9fe08f3fa1abda7d326ab.png

以下内容为转载: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下还支持管道连接方式。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值