龙空技术网

mysql启动时报错ERRORThe server quit without updatingPIDfile

爱音乐的程序员小新人 409

前言:

目前同学们对“如何启动mysql”大概比较注重,同学们都想要知道一些“如何启动mysql”的相关资讯。那么小编也在网摘上网罗了一些关于“如何启动mysql””的相关文章,希望朋友们能喜欢,小伙伴们一起来学习一下吧!

mysql启动时报如下错误:ERROR! The server quit without updating PID file (/data/mysql/localhost_002.pid).

[root@localhost_002 mysql]# /etc/init.d/mysqld startStarting MySQL. ERROR! The server quit without updating PID file (/data/mysql/localhost_002.pid).

查看错误日记时发现好多IonoDB的错误:

在百度上搜索到的结果及排查步骤如下:

1、可能是进程已经存在了mysql的进程:发现没有这个进程:

解决方法:用ps aux |grep msyql 查看,并且用kill -9 杀死,然后重启mysql;

[root@localhost_002 ~]# ps aux |grep mysqldroot 1176 0.0 0.0 112720 972 pts/0 S+ 22:07 0:00 grep --color=auto mysqld

2、可能是mysql的数据库目录所属主和组不是mysql,或者是没有执行权限;修改后还是不行;

[root@localhost_002 mysql]# chown -R mysql:mysql /data/mysql/[root@localhost_002 mysql]# chmod -R 755 /data/mysql/[root@localhost_002 mysql]# /etc/init.d/mysqld startStarting MySQL. ERROR! The server quit without updating PID file (/data/mysql/localhost_002.pid).

3、可能是第二次在机器上安装mysql,有残余数据影响了服务的启动;本机不存在这种类型的文件;

解决方法:去mysql的数据目录/data/mysql/看看,如果存在mysql-bin.index,就赶快把它删除掉;

4、mysql在启动时没有指定datadir:配置文件:/etc/my.cnf

[root@localhost_002 mysql]# vim /etc/my.cnfdatadir=/data/mysqlsocket=/tmp/mysql.sock[root@localhost_002 mysql]# service mysqld startStarting MySQL. ERROR! The server quit without updating PID file (/data/mysql/localhost_002.pid).

5、skip-federated字段问题;还是不行:

解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉;

6、selinux的问题:关闭它;

[root@localhost_002 mysql]# getenforceDisabled[root@localhost_002 ~]# service mysqld startStarting MySQL. ERROR! The server quit without updating PID file (/data/mysql/localhost_002.pid).

无果,再次查看日记如下:

2018-10-04 22:19:59 2510 [Note] InnoDB: Initializing buffer pool, size = 128.0M2018-10-04 22:19:59 2510 [Note] InnoDB: Completed initialization of buffer pool2018-10-04 22:19:59 2510 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!2018-10-04 22:19:59 2510 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB2018-10-04 22:19:59 2510 [Note] InnoDB: Database physically writes the file full: wait...2018-10-04 22:19:59 2510 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB2018-10-04 22:20:00 2510 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2018-10-04 22:20:02 2510 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02018-10-04 22:20:02 2510 [Warning] InnoDB: New log files created, LSN=457812018-10-04 22:20:02 2510 [Note] InnoDB: Doublewrite buffer not found: creating new2018-10-04 22:20:02 2510 [Note] InnoDB: Doublewrite buffer created2018-10-04 22:20:02 2510 [Note] InnoDB: 128 rollback segment(s) are active.

看到有关./ib_logfie101的文件:进入到mysql的数据库目录下,删除这些ib开头文件(删除前建议先备份下,不然数据会丢失);

[root@localhost_002 ~]# cd /data/mysql/[root@localhost_002 mysql]# ls aria_log_control ib_buffer_pool ib_logfile0 ib_logfile101 multi-master.info performance_schema aria_log.00000001 auto.cnf ibdata1 ib_logfile1 localhost_002.err mysql test[root@localhost_002 mysql]# rm -fr ib\_*[root@localhost_002 mysql]# rm -fr ibdata*[root@localhost_002 mysql]# /etc/init.d/mysqld startStarting MySQL.... SUCCESS! 

此时发现可以正常启动了:

查看下相关进程: ps aux |grep msyqld

[root@localhost_002 mysql]# ps aux |grep mysqldroot 2359 0.0 0.1 113308 1632 pts/0 S 22:19 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost_002.pidmysql 2510 0.0 46.2 1305940 462072 pts/0 Sl 22:19 0:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost_002.err --pid-file=/data/mysql/localhost_002.pid --socket=/tmp/mysql.sockroot 2558 0.0 0.0 112720 972 pts/0 S+ 22:49 0:00 grep --color=auto mysqld

标签: #如何启动mysql