Cannot start mysqld on centos because I cannot find mysql.sock

Hi, when I try to start my mysqld, I get this error:

[ root@localhost /]# service mysqld restart Stopping mysqld: [ OK ] MySQL Daemon failed to start. Starting mysqld: [FAILED] 

The main reason is because the my.cnf file cannot find my mysql.sock file.

 [ root@localhost /]# mysqladmin -u root -p status mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists! 

When I try to search:

 sudo find / -type s | grep mysqld.sock 

I will get

 find: '/proc/3253/task/3253/fd/5': Bestand of map bestaat niet find: '/proc/3253/task/3253/fdinfo/5': Bestand of map bestaat niet find: '/proc/3253/fd/5': Bestand of map bestaat niet find: '/proc/3253/fdinfo/5': Bestand of map bestaat niet "Bestand of map bestaat niet" == "File or directory don't exists" 

I'm new to this, so who can help me?

+7
linux mysql centos6
source share
6 answers

Such a pain! I came across the same problem (on RedHat) and this helped me:

 service mysqld stop rm -rf /var/lib/mysql/* service mysqld start mysql_secure_installation 

Hope this helps. Good luck

+14
source share

"the main reason is that the my.cnf file cannot find my mysql.sock file."

Nope. "MAJOR CAUSE" - mysqld has not started , so there is no mysql.sock, and any client cannot establish a connection.

Currently, "why mysqld failds" is a broad question. There is a reason in the MySQL error log "Why MySQL is not working." If you know where the mysql error log is located, just open it and send an error message to the question.

But probably, I think you do not know where the mysql error log is located ....

Determine where mysql error log is located

So, we need to determine where it is. we could guess somewhere ... but the exact approach uses strace

 $ strace -f > strace.log 2>&1 service mysqld start 

strace.log now has all the system calls related to MySQL Deamon. Open strace.log with any editor and find "err". in my case

 [pid 26976] open("/XXX/hostname.err", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3 

when open () fails

open() may crash, a common error

  • '2' for "no such file or directory" means "no directory / XXX.
  • '3' for 'permission denied' means that you (or the user in my.cnf) do not have the right to write to 'XXX'

so you can find why mysqld does not start in '/XXX/hostname.err'. We appreciate if you post an error message.

ps

I have test strace with

 $ strace -f > strace.log 2>&1 mysql.server start 

Not sure what works with service mysqld , but no reason not to work

UPDATE

"I get nothing in return: $ strace -f> strace.log 2> & 1 service mysqld start"

In fact, service mysqld start calls /etc/rc.d/init.d/mysqld start (assuming CentOS or Fedora). so you can try.

 $ strace -f > strace.log 2>&1 /etc/rc.d/init.d/mysqld start 

If the my.cnf you are referencing is the correct file for mysqld, open it and search for [mysqld] . It looks like this

 [mysqld] user = username port = 1111 basedir = /path/ datadir = /path/data 

The MySQL error log is located in /path/data

+3
source share

Not an expert in mysql, but the question is:

Does mysql serve as a socket, on the tcp port, or both?

check the my.cnf configuration file, which is usually located in / etc or / etc / mysql, and you will see it. In addition, if it is already running as a socket, you will see the path to the socket.

Hope this helps.

Hi

+1
source share

From your post, it seems mysqld failed to start MySQL Daemon failed to start. Starting mysqld: [FAILED] MySQL Daemon failed to start. Starting mysqld: [FAILED] .

Check if mysqld service mysqld status working.

The my.cnf configuration file is looking for mysql.sock, and you were looking for mysqld.sock. Two different names.

+1
source share

Thanks, Barmaley, for the awesome answer. I checked the mysqld.log file.

Shows all the reasons why my mysql service does not start. In my case, the mysql user does not have write permission for "/ var / run / mysqld" . I gave permission to the mysql user as root, and it worked for me.

Thanks again! Barmaley

+1
source share

Tech Setup:

 Vagrant (Centos 6.6, MySQL 6.6) on top of MacOS Captain 

Every time I try to run mysql on Centos, I see this problem, I'm not sure if this problem is specific only to the OS and version of MySQL.

If you open the log files and make sure you see something like this

/ usr / sbin / mysqld: File '/var/log/mysql-bin.index' not found (Errcode: 13 - Permission denied)

This Permission Denied is that by default we do not have write permissions to the / var / log files, so we must change the permissions for the user. MySQL is trying to write something to bin-log or relay-logs located in /var/log/mysql .

Before we change permissions, we need to understand that there is no mysql directory in the / var / log directory, so we need to create this first, and then change the permissions. So, I did this:

 mkdir mysql chown mysql: mysql 

mysqld should start working now!

0
source share

All Articles