您的位置:首页 > 数据库 > MySQL

mysql初始化后找不到pid 不能启动

2014-04-03 15:15 288 查看
虚拟机centos 6.4 64位安装的mysql 5.5.37,修改了my.cnf配置
[root@localhost etc]# service mysqld start  #启动mysql失败
Starting MySQL.... ERROR! The server quit without updating PID file (/home/mysql/log/mysql.pid).

[root@localhost etc]# tail -n 30 /home/mysql/log/mysql-error.log  #首先查看日志
。。。。
140918 07:27:20 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data
140918  7:27:20 [Warning] Although a path was specified for the --log-slow-queries option, log tables are used. To enable logging to files use the --log-output=file option.
140918  7:27:21 InnoDB: The InnoDB memory heap is disabled
140918  7:27:21 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140918  7:27:21 InnoDB: Compressed tables use zlib 1.2.3
140918  7:27:21 InnoDB: Initializing buffer pool, size = 4.0G
140918  7:27:22 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file /home/mysql/data/ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 536870912 bytes!
140918  7:27:22 [ERROR] Plugin 'InnoDB' init function returned error.
140918  7:27:22 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140918  7:27:22 [ERROR] Unknown/unsupported storage engine: INNODB
140918  7:27:22 [ERROR] Aborting
140918  7:27:22 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
140918 07:27:22 mysqld_safe mysqld from pid file /home/mysql/log/mysql.pid ended

[root@localhost etc]# rm /home/mysql/data/ib_logfile*
rm: remove regular file `/home/mysql/data/ib_logfile0'? y
rm: remove regular file `/home/mysql/data/ib_logfile1'? y

[root@localhost etc]# service mysqld start
Starting MySQL..................................................................................................... SUCCESS!
OK,由于修改了innodb的innodb_buffer_pool_size参数,所以需要删除原来的ib_logfile,在第一次启动的时候因为要创建,所以较慢
另一次由于做实验,需要把里面数据都清除了。启动mysql,一直提示不能创建pid,不能创建pid文件,看日志,检查mysql对目录的权限
mysqld_safe mysqld from pid file/usr/local/mysql/data/localhost.localdomain.pid ended发现原来是初始化mysql之前,进程没有kill掉 (初始化mysql之前应该service mysqld stop) 初始化mysql
[root@localhost ~]#cd /usr/local/mysql/
[root@localhost mysql]# cd data/
[root@localhost data]# ls
ibdata1      ib_logfile1               localhost.localdomain.pid  performance_schema
ib_logfile0  localhost.localdomain.err  mysql                     test
[root@localhost data]# rm -rf *
[root@localhost data]# cd ..
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/ [root@localhost mysql]# ./bin/mysqld_safe &
[1] 11035
[root@localhost mysql]#
140401 15:24:03 mysqld_safe Logging to'/usr/local/mysql/data/localhost.localdomain.err'.
140401 15:24:03 mysqld_safe Starting mysqld daemon with databases from/usr/local/mysql/data
140401 15:24:05 mysqld_safe mysqld from pid file/usr/local/mysql/data/localhost.localdomain.pid ended
[1]+  Done                   ./bin/mysqld_safe
[root@localhost mysql]# ps aux|grep mysql
root     10718  0.0  0.1 106192  1536 pts/0   S    15:20   0:00 /bin/sh ./bin/mysqld_safe
mysql    10948  0.1  4.0 731840 40996 pts/0    Sl  15:20   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql--datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin--user=mysql --log-error=/usr/local/mysql/data/localhost.localdomain.err--pid-file=/usr/local/mysql/data/localhost.localdomain.pid--socket=/usr/local/mysql/mysql.sock --port=3306
root     11284  0.0  0.0 103240   860 pts/1   S+   15:24   0:00 grep mysql
[root@localhost mysql]# kill -9 10718
[root@localhost mysql]# kill -9 10948
[root@localhost mysql]# service mysqld restart
ERROR! MySQL server PID file could notbe found!
Starting MySQL.. SUCCESS!
以后出问题后还是自己分析问题最重要,不要一上来就去谷歌度娘查,会把思路带到另一个未知的方向1,查看日志mysql的错误日志 mysql-error.log2,查看进程 ps aux|grep mysql3,查看权限 ll /home/mysql4,查看history5,检查磁盘空间,df -h5,操作标准化,尽量做的规范,养成一个好习惯 附mysql 官方的编译文档,很有参考价值https://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html#cmake-installation-layout-options
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql 初始化 pid