mysql初始化报错:[ERROR] --initialize specified but the data directory has files in it. Aborting.

时间:2024-04-09 20:19:53

执行命令
mysqld --initialize --user=mysql报错如下mysql初始化报错:[ERROR] --initialize specified but the data directory has files in it. Aborting.
原因是你已经进行了数据库初始化因为mysql在进行初始化的时候已经自动创建了一个root用户
1找到配置文件的数据目录
[[email protected] mysql]# vim /etc/my.cnf
mysql初始化报错:[ERROR] --initialize specified but the data directory has files in it. Aborting.
2 找到数据库的目录将该目录进行备份,
mv data data_bac

重新初始化 就好了
mysql初始化报错:[ERROR] --initialize specified but the data directory has files in it. Aborting.
第二个报错:

ERROR! The server quit without updating PID file
(/usr/local/lnmp/mysql/data/server4.pid).

解决办法:给予数据库配置文件子755的权限,且将他的用户用户组都改为mysql
chown -R mysql:mysql /usr/local/lnmp/mysql/data/
chmod -R 755 /usr/local/lnmp/mysql/data
重新启动即可!
如果有已经存在的mysql kill -9 杀掉
ok!希望能帮助遇到困难的你