之前公司用的测试机,并没有清空原来使用数据,导致mysql,php ,nginx,apache多个环境版本,由于php版本是5.2,过于太低,方便测试 。本人就直接安装了集成环境,为方便测试。
通过排查mysql 日志和看文件目录
发现问题:mysql.sock 和 mysql pid 文件都丢失 导致mysql启动不了
mysqld_safe mysqld from pid file /phpstudy/data/lf-xgo-yanglin-web1.leftbrain.com.cn.pid ended
180929 09:02:02 mysqld_safe mysqld from pid file /phpstudy/data/lf-xgo-yanglin-web1.leftbrain.com.cn.pid ended
180929 09:04:35 mysqld_safe Starting mysqld daemon with databases from /phpstudy/data
^G/phpstudy/mysql/bin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
180929 9:04:35 [ERROR] Aborting180929 9:04:35 [Note] /phpstudy/mysql/bin/mysqld: Shutdown complete180929 09:04:35 mysqld_safe mysqld from pid file /phpstudy/data/lf-xgo-yanglin-web1.leftbrain.com.cn.pid ended
180929 09:11:53 mysqld_safe Starting mysqld daemon with databases from /phpstudy/data
^G/phpstudy/mysql/bin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
180929 9:11:53 [ERROR] Aborting180929 9:11:53 [Note] /phpstudy/mysql/bin/mysqld: Shutdown complete180929 09:11:53 mysqld_safe mysqld from pid file /phpstudy/data/lf-xgo-yanglin-web1.leftbrain.com.cn.pid ended
180929 09:12:03 mysqld_safe Starting mysqld daemon with databases from /phpstudy/data
^G/phpstudy/mysql/bin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
180929 9:12:03 [ERROR] Aborting
解决办法
通过mysql的bin目录下 mysqld_safe 重新生成 sock文件
./mysqld_safe --user=mysql --basedir=/phpstudy/mysql --datadir=/phpstudy/mysql/data &
再删除mysql 下data 目下的三个文件 ibdata1 ib_logfile0 ib_logfile1
最后重启环境完成,如果还是不行,你的数据又不是很重要, 直接简单粗暴有效的方法就是,重装mysql 最有效,要是搞不定请打死我!