当rm -rf /var/lib/mysql ,成功重起mysql库的步骤如下:
1、mkdir /var/lib/mysql
2、chown mysql:mysql /var/lib/mysql #(yum 安装的目测是会自动生成的)
3、将 /etc/my.cnf文件内容还原到初始状态
4、systemctl start mysql-------------------一般情况下就启动起来了
5、若没起来,rm -rf /var/lib/mysql/*
6、systemctl start mysql-------------------就肯定启动起来了
如何初始化mysql库 ?
# 注意 删除的是 rm -rf /var/lib/mysql 而不是 rm -rf /var/lib/mysql/mysql
[root@test01 mysql]# systemctl restart mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@test01 lib]# cd mysql
[root@test01 mysql]# ls
mysql ......
[root@test01 mysql]# cd ..
[root@test01 lib]# rm -rf mysql
[root@test01 lib]# ls
已删除 /var/lib/mysql 而不是 rm -rf /var/lib/mysql/mysql