Contents

mysql启动报错及解决办法

Contents

今天在编译Mysql后,启动mysql的时候出现

1
2
3
4
[root@sj-ovz-128 mysql]# service mysqld start  
/etc/init.d/mysqld: line 46: /usr/local/mysql: is a directory  
/etc/init.d/mysqld: line 47: /home/mysql/data: is a directory  
Starting MySQL. ERROR! The server quit without updating PID file (/home/mysql/data/sj-ovz-128.pid).  

查看/home/mysql/data 发现有sj-ovz-128.err

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[root@sj-ovz-128 data]# less sj-ovz-128.err  
130105 06:31:49 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data  
130105  6:31:49 InnoDB: The InnoDB memory heap is disabled  
130105  6:31:49 InnoDB: Mutexes and rw_locks use InnoDB's own implementation  
130105  6:31:49 InnoDB: Compressed tables use zlib 1.2.3  
130105  6:31:49 InnoDB: Initializing buffer pool, size = 128.0M  
130105  6:31:49 InnoDB: Completed initialization of buffer pool  
Plugin 'InnoDB' init function returned error.  
InnoDB: Error: pthread_create returned 11  
130105 06:31:49 mysqld_safe mysqld from pid file /home/mysql/data/sj-ovz-128.pid ended  
130105 06:32:52 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data 

里面有两处错误

1
2
Plugin 'InnoDB' init function returned error.  
InnoDB: Error: pthread_create returned 11

第一个 Plugin ‘InnoDB’ init function returned error. google 得出的答案是my.cnf配置文件的问题

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# my.cnf配置文件的问题  
# /etc/my.cnf来自以下文件:  
  
如果你的内存≤64M,则复制/usr/local/share/mysql/my-small.cnf为/etc/my.cnf  
# This is for a system with little memory (<= 64M) where MySQL is only used  
# from time to time and it's important that the mysqld daemon  
# doesn't use much resources.  
  
如果内存是128M,则复制/usr/local/share/mysql/my-medium.cnf为/etc/my.cnf  
# This is for a system with little memory (32M - 64M) where MySQL plays  
# an important part, or systems up to 128M where MySQL is used together with  
# other programs (such as a web server)  
  
如果内存是512M,则复制/usr/local/share/mysql/my-large.cnf为/etc/my.cnf  
# This is for a large system with memory = 512M where the system runs mainly  
# MySQL.  
  
如果内存是1-2G,则复制/usr/local/share/mysql/my-huge.cnf为/etc/my.cnf  
# This is for a large system with memory of 1G-2G where the system runs mainly  
# MySQL.

恰好我使用的是my-huge.cnf,而我的vps内存是128,照上面的方法解决了此错误

第二个 InnoDB: Error: pthread_create returned 11 我直接在ssh里面运行

1
root@sj-ovz-128 data]# ulimit -s unlimited

也可以禁用innodb来解决此问题,建议小内存vps使用此方法。有关innodb的信息请自行查阅相关资料。

在my.cnf的[mysqld]部分加入

1
2
default-storage-engine = MyISAM  
skip-innodb

成功解决