# question about socket

**URL:** https://forums.percona.com/t/question-about-socket/3329
**Category:** Percona Server for MySQL 5.6
**Created:** [March 12, 2014, 6:01am UTC](https://forums.percona.com/t/question-about-socket/3329 "2014-03-12T06:01:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mixa](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mixa/32/16881_2.png) [@mixa](https://forums.percona.com/u/mixa)
#### Post date: [March 12, 2014, 6:01am UTC](https://forums.percona.com/t/question-about-socket/3329/1 "2014-03-12T06:01:48Z")

</div>

Question to Percona Support:

* * *

Hello, Dear Percona

I download the Percona-Server-5.6.14-rel62.0-483.Linux.x86\_64.tar from the [percona.com](http://percona.com).

When I tar this file and try to execute the mysql command, it gives me the error  
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

But in my my.cnf, I set the sock=/var/lib/mysql/mysql.sock.

I know that if I make a link-file to point this real socket file in the /var/lib/mysql dir can reslove this problem.

But I want to know how the /app/mysql/bin/mysql to executed. Why it find the socket file from the /tmp dir.

Is this can be configure in the Percona or in the RedHat System?

Below is my uname -a result:  
2.6.32-262.el6.x86\_64 #1 SMP Sun Apr 8 18:38:00 EDT 2012 x86\_64 x86\_64 x86\_64 GNU/Linux

I am waiting for your apply, thanks a lot!

* * *

李宋高

---

<div class="post-metadata">

### Author: ![mixa](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mixa/32/16881_2.png) [@mixa](https://forums.percona.com/u/mixa)
#### Post date: [March 12, 2014, 6:21am UTC](https://forums.percona.com/t/question-about-socket/3329/2 "2014-03-12T06:21:32Z")

</div>

Hi,

The default socket path for MySQL 5.6 is ‘/tmp/mysql.sock’.  
[http://dev.mysql.com/doc/refman/5.6/](http://dev.mysql.com/doc/refman/5.6/)…\_mysqld\_socket

So if you have non-default socket place specified in my.cnf ([mysqld] section) then you can connect to mysql by the following ways:

- specify socket explicitly in connection string:  
mysql -u root -p -S /var/lib/mysql/mysql.sock

OR

- add the socket info to [client] section in my.cnf (and restart mysql) so your config file will be looking like below:  
[mysqld]  
…  
socket = /var/lib/mysql/mysql.sock

[client]  
…  
socket = /var/lib/mysql/mysql.sock

In this case you’ll be able to connect w/o specifying socket, like below:  
mysql -u root -p

That’s because:

- socket in [mysqld] - the path where server will place a .sock file
- socket in [client] - the path where will be looking for .sock file while connecting

By default both variables are ‘/tmp/mysql.sock’

You can read more related info there:  
[URL=“[MySQL :: MySQL 5.6 Reference Manual :: 4.2.2.2 Using Option Files](http://dev.mysql.com/doc/refman/5.6/en/option-files.html)”][http://dev.mysql.com/doc/refman/5.6/...ion-files.html[/URL]](http://dev.mysql.com/doc/refman/5.6/...ion-files.html%5B/URL%5D)

---

<div class="post-metadata">

### Author: ![Coca\_Li](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@Coca\_Li](https://forums.percona.com/u/Coca_Li)
#### Post date: [March 12, 2014, 7:28am UTC](https://forums.percona.com/t/question-about-socket/3329/3 "2014-03-12T07:28:38Z")

</div>

Hi, Dear Michael

I am Li, thanks for your apply.

I didn’t find any .my.cnf in my Percona basedir, even all of my / dir.  
[root@MYSQL\_01 mysql]# find / -name ‘.my.cnf’  
[root@MYSQL\_01 mysql]#

It seams the strace output is null.  
[root@MYSQL\_01 bin]# pwd  
/app/mysql/bin  
[root@MYSQL\_01 bin]# strace -f -e trace=open mysql 2\>&1 | grep -i cnf  
[root@MYSQL\_01 bin]#

---

<div class="post-metadata">

### Author: ![mixa](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mixa/32/16881_2.png) [@mixa](https://forums.percona.com/u/mixa)
#### Post date: [March 12, 2014, 9:33am UTC](https://forums.percona.com/t/question-about-socket/3329/4 "2014-03-12T09:33:12Z")

</div>

some logs…

###################################  
my.cnf  
###################################

[root@MYSQL\_01 ~]# cat /app/mysql/my.cnf  
[mysqld]  
datadir=/app/mysql/data  
socket=/var/lib/mysql/mysql.sock  
user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

[client]  
socket=/var/lib/mysql/mysql.sock

[mysqld\_safe]  
log-error=/app/mysql/mysqld.log  
pid-file=/app/mysql/mysqld.pid

###################################  
process:  
###################################  
[root@MYSQL\_01 ~]# ps -ef | grep mysqld  
root 3425 1 0 05:07 pts/0 00:00:00 /bin/sh /app/mysql/bin/mysqld\_safe --datadir=/app/mysql/data --pid-file=/app/mysql/data/MYSQL\_01.pid  
mysql 3591 3425 10 05:07 pts/0 00:00:00 /app/mysql/bin/mysqld --basedir=/app/mysql --datadir=/app/mysql/data --plugin-dir=/app/mysql/lib/mysql/plugin --user=mysql --log-error=/app/mysql/mysqld.log --pid-file=/app/mysql/data/MYSQL\_01.pid --socket=/var/lib/mysql/mysql.sock  
root 3618 3103 0 05:07 pts/0 00:00:00 grep mysqld

###################################

BUT:  
[root@MYSQL\_01 ~]# mysql  
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

---

<div class="post-metadata">

### Author: ![mixa](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mixa/32/16881_2.png) [@mixa](https://forums.percona.com/u/mixa)
#### Post date: [March 12, 2014, 10:09am UTC](https://forums.percona.com/t/question-about-socket/3329/5 "2014-03-12T10:09:08Z")

</div>

Hi Li,

Can you try to move my.cnf to default place (/etc/my.cnf) and restart mysql?  
Just to try if this will be helpful.

OR

You can also try the following:

sudo -i  
mysqld --defaults-file=/app/mysql/my.cnf &

then try to connect.

---

<div class="post-metadata">

### Author: ![Coca\_Li](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@Coca\_Li](https://forums.percona.com/u/Coca_Li)
#### Post date: [March 19, 2014, 3:20am UTC](https://forums.percona.com/t/question-about-socket/3329/6 "2014-03-19T03:20:28Z")

</div>

Hi, mixa

It seams you changed the name? Or maybe I was missing.  
I delete the default /etc/my.cnf all ready for this test.  
Maybe I think this is the OS problem. As you know, some packages maybe included in the OS.  
When I executed mysql, may this bin file is not Percona’s mysql.  
I will try to executed /app/mysql/bin/mysql and watch it’s out.

Thanks a lot for your help and be sorry for update so late.
