can't start mysqld on centos because I cant find mysql.sock
What a pain! I stumbled upon same problem (on RedHat) and this helped me:
service mysqld stoprm -rf /var/lib/mysql/*service mysqld startmysql_secure_installation
Hope that helps. Good luck!
"the main reason is that my.cnf file can't find my mysql.sock file."
Nope. "THE MAIN REASON" is mysqld has not started
, so there is no mysql.sock and any client cannot establish connection.
Currently "why mysqld failds" is broad question. MySQL Error log has the reason 'Why MySQL fails'. If you know where mysql error log is, just open it, and post error message into you question.
But probably I guess you don't know where mysql error log is....
Identify where mysql error log is
So, we need to identify where it is. we could guess somewhere... but the exact approach is using strace
$ strace -f > strace.log 2>&1 service mysqld start
now strace.log has all system call related to MySQL Deamon. open strace.log with any editor and search 'err"'. in my case
[pid 26976] open("/XXX/hostname.err", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3
when open() fails
It could happen open()
fails, common error is
- '2' for 'no such file or directory' means 'there is no /XXX directory.
- '3' for 'permission denied' means you (or user in my.cnf) don't have write permission on 'XXX'
so you can find why mysqld fails to start in '/XXX/hostname.err'. we highly appreciate if you post error message.
p.s.
I have test strace with
$ strace -f > strace.log 2>&1 mysql.server start
Not sure working with service mysqld
, but no reason not to work
UPDATE
"I don't get anything in return with: $ strace -f > strace.log 2>&1 service mysqld start "
Actually service mysqld start
invokes /etc/rc.d/init.d/mysqld start
(assuming CentOS or Fedora). so, you could try.
$ strace -f > strace.log 2>&1 /etc/rc.d/init.d/mysqld start
If my.cnf
which you referenced is right file for mysqld, open it and search [mysqld]
section. It looks like as follows
[mysqld]user = usernameport = 1111basedir = /path/datadir = /path/data
MySQL error log is in /path/data
Am not an expert in mysql but the question is:
Is mysql listening on a socket, on a tcp port or both?
check the my.cnf configuration file which usually is in /etc or /etc/mysql and you will see this. Also, if it is already running as a socket, you will see the path to the socket.
Hope it helps.
Regards