报错描述:
1、mysql安装好后,启动mysql服务时报错:
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
2、根据提示输入指令查日志
journalctl -xe
看到日志中具体的报错信息为:
[ERROR] --initialize specified but the data directory has files in it. Aborting.
猜测应该是之前装的mysql数据文件有残留,数据库无法初始化
解决方法
- 查看数据存储目录
vim /etc/my.cnf
找到my.cnf文件中的datadir,复制下来
2、移除目录
rm -rf /usr/local/mysql_data/
3、mysql初始化
mysqld --initialize
4、重启mysql服务
systemctl start mysqld