MySQL Daemon Failed to Start - centos 6
Asked Answered
B

17

19

EDIT: Look at the checkmarked answer comments to get your issue solved.

Whenever I try to start the SQLD service I get MySQL Daemon Failed to Start. I infact tried to "start" the service by doing the following:

service mysqld start

Also

When I type: mysql

I get:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I know that there should be a mysql.sock file in that directory, so I create one. But the file just auto removes its self and I continue to get the error 2002.

I am also unable to log into PHPMyAdmin due to the error. I can access phpmyadmin page but when logging in I get: #2002 Cannot log in to the MySQL server

EDIT:

Here is my mysql.log file:

131201 13:05:07 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
131201 13:18:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
131201 13:18:18 [Note] Plugin 'FEDERATED' is disabled.
/usr/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
131201 13:18:18 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
131201 13:18:18 InnoDB: The InnoDB memory heap is disabled
131201 13:18:18 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131201 13:18:18 InnoDB: Compressed tables use zlib 1.2.3
131201 13:18:18 InnoDB: Using Linux native AIO
131201 13:18:18 InnoDB: Initializing buffer pool, size = 128.0M
131201 13:18:18 InnoDB: Completed initialization of buffer pool
131201 13:18:18  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
131201 13:18:18 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I ran mysql_upgrade and got

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed
Bucksaw answered 1/12, 2013 at 9:40 Comment(4)
Are you sure mysqld is running? Try service mysqld status to see. If not:service mysqld start MySQL on CentosLogographic
I forgot to add when I try to start the mysqld service I get the MySQL Daemon error.Bucksaw
Exactly what error message? Also, try sudo service mysql start. And possibly get rid of that mysql.sock file you manually created.Logographic
As I said, it automatically removes it.Bucksaw
R
19

The most likely cause for this error is that your mysql server is not running. When you type in mysql you are executing mysql client.

Try:

# sudo service mysql start
# mysql

Update (after OP included log in the question; taken from the comments below):

Thanks, saw your log. The log is saying the mysql user doesn't have proper access rights. I'm assuming your mysql user is mysql(this can be verified in /etc/my.cnf, execute

chown -R mysql:mysql /var/lib/mysql

and try starting mysqld again.

Rosenwald answered 1/12, 2013 at 9:44 Comment(5)
The screenshot shows that you're already logged in as root, so you do not need to use sudo. You could just do service mysqld start. Please post any errors you get when you issue this command.Rosenwald
Seems like I confused a few people with how I wrote this post. When I do 'service mysqld start' I get MySQL Daemon Failed to Start. Another issue was I get "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)" when typing "mysql".Bucksaw
Do you have mysqld.log file, can you post the relevant portion of the log when you execute service mysqld start.Rosenwald
I have added it to the main question.Bucksaw
Thanks, saw your log. The log is saying the mysql user doesn't have proper access rights. I'm assuming your mysql user is mysql(this can be verified in /etc/my.cnf, execute chown -R mysql:mysql /var/lib/mysql and try starting mysqld again.Rosenwald
E
22

Try restarting apache sudo service httpd restart. Worked for me.

Equilateral answered 24/3, 2014 at 1:53 Comment(6)
I don't know why but to my horror this ACTUALLY WORKED !! Thanks raindrop !!Loria
It worked for me as well... I'm intrigued about the answer to this.Fourwheeler
I don't know how it works, but when have problems with MySQL, PHP etc. I sometimes restart the web service as part of general debugging.Equilateral
@stcheng it's too late but i was also curios since last one month, but today i had figured out why is it working after httpd restart. actually the reason is memory atleast in my case, mysql goes down when there is memory issue but when i do httpd restart may be due to some memory released mysql gets enough memory to start againSpann
This fix did not make any sense to me but tried it out after trying out a few other things and it worked. I had to stop httpd on my machine and then tried starting mysqld... and it worked!!!... absolutely no idea why.Annamariaannamarie
I think i figured out how httpd was impacting the start of mysql server on my instance. I believe my micro instance ran out of memory. (support.plesk.com/hc/en-us/articles/…)Annamariaannamarie
R
19

The most likely cause for this error is that your mysql server is not running. When you type in mysql you are executing mysql client.

Try:

# sudo service mysql start
# mysql

Update (after OP included log in the question; taken from the comments below):

Thanks, saw your log. The log is saying the mysql user doesn't have proper access rights. I'm assuming your mysql user is mysql(this can be verified in /etc/my.cnf, execute

chown -R mysql:mysql /var/lib/mysql

and try starting mysqld again.

Rosenwald answered 1/12, 2013 at 9:44 Comment(5)
The screenshot shows that you're already logged in as root, so you do not need to use sudo. You could just do service mysqld start. Please post any errors you get when you issue this command.Rosenwald
Seems like I confused a few people with how I wrote this post. When I do 'service mysqld start' I get MySQL Daemon Failed to Start. Another issue was I get "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)" when typing "mysql".Bucksaw
Do you have mysqld.log file, can you post the relevant portion of the log when you execute service mysqld start.Rosenwald
I have added it to the main question.Bucksaw
Thanks, saw your log. The log is saying the mysql user doesn't have proper access rights. I'm assuming your mysql user is mysql(this can be verified in /etc/my.cnf, execute chown -R mysql:mysql /var/lib/mysql and try starting mysqld again.Rosenwald
B
12

run this :

chown -R mysql:mysql /var/lib/mysql

and try again!

Businesslike answered 1/12, 2013 at 10:16 Comment(0)
H
6

You may need free up some space from root (/) partition. Stop mysql process by:

/etc/init.d/mysql stop

Delete an unused database from mySql by command:

rm -rf [Database-Directory]

Execute it in /var/lib/mysql. Now if you run df -h, you may confused by still full space. For removing the unused database 's directory to be affected, you need to kill processes are using current directory/partition.

Stopping mysql_safe or mysqld_safe and then mysqld:

ps -A

Then find mysql's process number (e.g. 2234). Then execute:

kill 2234

Now start again mysql:

/etc/init.d/mysql start
Hoehne answered 17/2, 2014 at 4:20 Comment(0)
J
6
 /etc/init.d/mysqld stop

 mysqld_safe --skip-grant-tables & mysql_upgrade

 /etc/init.d/mysqld stop

 /etc/init.d/mysqld start
Jussive answered 13/6, 2017 at 14:44 Comment(1)
Some explanation would be nice. Also please format your answer with code blocks.Avocado
H
3

Yet another tip that worked for me. Run the command:

$ mysql_install_db
Hydrargyrum answered 22/4, 2014 at 22:23 Comment(0)
P
2
  1. /etc/init.d/mysql stop
  2. chown -R mysql:mysql /var/lib/mysql
  3. mysql_install_db
  4. /etc/init.d/mysql start

All this rescued my MySQL server!

Paschal answered 31/1, 2015 at 13:34 Comment(0)
K
2

For those who will be here in the future, if all above methods are not working, check the my.cnf file by:

$ sudo gedit /etc/my.cnf

Find the line start with:

bind-address=[an-IP-address]

Check if the IP address after the equal sign is correct. If you don't even know what the IP is, just use localhost, then you can only connect to MySQL inside the same host.

If you want to connect to MySQL remotely, you should actually comment out that line entirely, then it will listen on all IPs and ports which you need because you will be connecting remotely to it over public IPv4.

After that add a user to access your database such as:

mysql> GRANT ALL ON database_name.* TO [email protected] IDENTIFIED BY 'your_password';

Replace xx.xx.xx.xx with your local IP address of your laptop/desktop or if it is dynamic you can add them either by: '192.168.0.%' as a dynamic C-class or '%' if you want to be able to connect from anywhere (this is less secure)

Also, if there's a firewall installed, one should open the port on the firewall;

For example in Ubuntu:

sudo ufw allow 3306/tcp
sudo service ufw restart

Now, check if the service is startable by:

$ sudo service mysqld start
Kanal answered 17/8, 2017 at 5:42 Comment(0)
S
1

try

netstat -a -t -n | grep 3306 

to see any one listening to the 3306 port then kill it

I was having this problem for 2 days. Trying out the solutions posted on forums I accidentally ran into a situation where my log was getting this error

check that you do not already have another mysqld process

Siltstone answered 20/5, 2014 at 1:5 Comment(0)
B
1

I had the same issue happening. When I checked the error.log I found that my disk was full.

Use:

df -h 

on the command line. it will tell you how much space you have left. mine was full. found my error.log file was 4.77GB. I downloaded it and then deleted it. Then I used service mysqld start and it worked.

Barmecide answered 6/11, 2015 at 19:57 Comment(0)
K
1

If you are using yum in AIM Linux Amazon EC2. For security, make a backup complete of directory /var/lib/mysql

sudo yum reinstall -y mysql55-server

sudo service mysqld start
Koby answered 8/7, 2016 at 0:43 Comment(0)
S
1

Your database was shut down because of insufficient memory! You can edit the file my.cnf base below graph to resolve it

performance_schema_max_table_instances=200
table_definition_cache=200
table_open_cache=128
Staw answered 6/7, 2017 at 6:40 Comment(1)
Do not forget to restart the databaseStaw
M
0

I just had this error. I could not connect remotely to my mysql server. I tried restarting mysql server with service mysqld restart (I used root). It stopped but did not start again. Turns out my memory was full. Cleared out a few GBs and it is working fine.

Marten answered 13/3, 2014 at 19:51 Comment(0)
E
0

It may be a permission issue,

Please try the following command /etc/init.d/mysqld start as root user.

Egon answered 6/6, 2014 at 4:28 Comment(0)
B
0

Reference here 2.10.2.1 Troubleshooting Problems Starting the MySQL Server.

1.Find the data directory ,it was configured in my.cnf.

[mysqld]
datadir=/var/lib/mysql

2. Check the err file,it log the error message about why mysql server start failed. the name of err file is related with your hostname.

cd /var/lib/mysql
ll
tail (hostname).err

3.If you find some messages like :

InnoDB: Error: log file ./ib_logfile0 is of different size 0 33554432 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
170513 14:25:22 [ERROR] Plugin 'InnoDB' init function returned error.
170513 14:25:22 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170513 14:25:22 [ERROR] Unknown/unsupported storage engine: InnoDB
170513 14:25:22 [ERROR] Aborting

then

delete ib_logfile0 and ib_logfile1

, then,

/etc/init.d/mysqld start
Belting answered 13/5, 2017 at 6:56 Comment(0)
M
0

RE: MySQL Daemon Failed to Start - centos 6 / RHEL 6

  1. Yum Install MySQL
  2. /etc/init.d/mysqld start MySQL Daemon failed to start. Starting mysqld: [FAILED]

  3. Review The log: /var/log/mysqld.log

  4. You might get this error: [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

Solution that works for me is running this:

  1. $ mysql_install_db

Please let me know if this won't solve your issue.

Missive answered 7/6, 2017 at 15:11 Comment(0)
M
0

what helped me was to add the following lines to /etc/my.cnf

innodb_force_recovery=4

and then sudo service mysqld start

worked like charm

Markman answered 29/8, 2022 at 21:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.