mysql初始化失败,报错如下:
2020-10-13T02:25:14.883062Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2020-10-13T02:25:14.883092Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2020-10-13T02:25:14.883143Z 0 [ERROR] [MY-010119] [Server] Aborting
解决:
cd /var/lib/mysql
rm -rf *
完成后重新初始化
/usr/sbin/mysqld --initialize --user=mysql
初始化完成会在页面打印密码,如果没有请在/var/log/mysql/mysqld.log中获取密码
登陆之前记得先启动服务:
systemctl start mysqld
登陆mysql:
mysql -uroot -p
修改密码:
alter user 'root'@'localhost' identified by 'new-passwd';