php MySQL 守护进程无法启动 - centos 6
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20310782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL Daemon Failed to Start - centos 6
提问by Travis
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:
每当我尝试启动 SQLD 服务时,我都会遇到 MySQL Daemon Failed to Start。我实际上尝试通过执行以下操作来“启动”服务:
service mysqld start
Also
还
When I type: mysql
当我输入: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.
我知道那个目录中应该有一个 mysql.sock 文件,所以我创建了一个。但是文件只是自动删除了它自己,我继续收到错误 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
由于错误,我也无法登录 PHPMyAdmin。我可以访问 phpmyadmin 页面,但登录时我得到:#2002 Cannot log in to the MySQL server
EDIT:
编辑:
Here is my mysql.log file:
这是我的 mysql.log 文件:
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
我跑了 mysql_upgrade 并得到
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed
采纳答案by vee
The most likely cause for this error is that your mysql server is not running. When you type in mysqlyou are executing mysql client.
此错误的最可能原因是您的 mysql 服务器未运行。当您输入时,mysql您正在执行 mysql 客户端。
Try:
尝试:
# sudo service mysql start
# mysql
Update(after OP included log in the question; taken from the comments below):
更新(在 OP 包含登录问题之后;摘自下面的评论):
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/mysqland try starting
mysqldagain.
谢谢,看到你的日志了。日志说 mysql 用户没有适当的访问权限。我假设你的 mysql 用户是 mysql(这可以在 中验证
/etc/my.cnf,执行
chown -R mysql:mysql /var/lib/mysql并尝试
mysqld重新开始。
回答by hexicle
Try restarting apache sudo service httpd restart. Worked for me.
尝试重新启动 apache sudo service httpd restart。为我工作。
回答by Mehdi
run this :
运行这个:
chown -R mysql:mysql /var/lib/mysql
and try again!
然后再试一次!
回答by Mohsen Abasi
You may need free up some space from root (/) partition. Stop mysql process by:
您可能需要从根 (/) 分区释放一些空间。通过以下方式停止 mysql 进程:
/etc/init.d/mysql stop
Delete an unused database from mySql by command:
通过命令从 mySql 中删除一个未使用的数据库:
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.
中执行/var/lib/mysql。现在,如果您运行df -h,您可能会对仍然充满空间感到困惑。要删除受影响的未使用数据库的目录,您需要终止正在使用当前目录/分区的进程。
Stopping mysql_safeor mysqld_safeand then mysqld:
停止mysql_safe或mysqld_safe然后mysqld:
ps -A
Then find mysql's process number (e.g. 2234). Then execute:
然后找到mysql的进程号(如2234)。然后执行:
kill 2234
Now start again mysql:
现在重新启动mysql:
/etc/init.d/mysql start
回答by guru rajender
/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables &
mysql_upgrade
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
回答by dxvargas
Yet another tip that worked for me. Run the command:
另一个对我有用的技巧。运行命令:
$ mysql_install_db
回答by Dmitry Kovalev
/etc/init.d/mysql stopchown -R mysql:mysql /var/lib/mysqlmysql_install_db/etc/init.d/mysql start
/etc/init.d/mysql stopchown -R mysql:mysql /var/lib/mysqlmysql_install_db/etc/init.d/mysql start
All this rescued my MySQL server!
这一切拯救了我的 MySQL 服务器!
回答by Ken
I had the same issue happening. When I checked the error.log I found that my disk was full.
我遇到了同样的问题。当我检查 error.log 时,我发现我的磁盘已满。
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.
在命令行上。它会告诉你还剩多少空间。我的已经满了。发现我的 error.log 文件是 4.77GB。我下载了然后删除了。然后我使用了 service mysqld start 并且它起作用了。
回答by haichao hu
Your database was shut down because of insufficient memory! You can edit the file my.cnf base below graph to resolve it
你的数据库因为内存不足被关闭了!你可以编辑下图的my.cnf文件来解决
performance_schema_max_table_instances=200
table_definition_cache=200
table_open_cache=128
回答by Duc Filan
For those who will be here in the future, if all above methods are not working, check the my.cnf file by:
对于那些将来会在这里的人,如果以上所有方法都不起作用,请通过以下方式检查 my.cnf 文件:
$ 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.
检查等号后的IP地址是否正确。如果你连IP是什么都不知道,就用localhost,那么你只能连接到同一主机内的MySQL。
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.
如果您想远程连接到 MySQL,您实际上应该完全注释掉该行,然后它将侦听您需要的所有 IP 和端口,因为您将通过公共 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)
将 xx.xx.xx.xx 替换为您的笔记本电脑/台式机的本地 IP 地址,或者如果它是动态的,您可以通过以下方式添加它们:“192.168.0.%”作为动态 C-class 或“%”(如果需要)能够从任何地方连接(这不太安全)
Also, if there's a firewall installed, one should open the port on the firewall;
此外,如果安装了防火墙,则应打开防火墙上的端口;
For example in Ubuntu:
例如在 Ubuntu 中:
sudo ufw allow 3306/tcp
sudo service ufw restart
Now, check if the service is startable by:
现在,检查服务是否可以通过以下方式启动:
$ sudo service mysqld start

