1. [Mysql initialization configuration]:
[root@localhost cdrom]# cd /usr/local/bin
[root@localhost bin]# mysqld - -initialize - -user=mysql
[root@localhost bin]# mysqld - -initialize-insecure - -user=mysql
[root@dns lib]# vim /etc/my.cnf
In this file insert: skip-grant-tables
Note: Edit the MySQL configuration file, set it to allow empty password login, and insert this line in the file! Remember to delete this line of code after setting the My SQL password! Because it’s not safe! ! !
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
2. MySQL initialization failed, resulting in continuous startup failure:
solution:
What should I do if MySQL initializes an error?
Solution:
Enter the /var/lib/ directory to see if there is a mysql directory, and delete it if there is:
[ root @ dns bin ] # cd / var / lib
[root@dns lib]# rm -rf mysql
[root@dns lib]# cd /usr/local/bin/
[root@dns bin]# mysqld --initialize-insecure --user=mysql
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
If that still doesn't work, then:
[ root @ dns bin ] # cd / var / lib
[root@dns lib]# rm -rf mysql
[root@dns lib]# cd /usr/local/bin/
[root@dns bin]# mysqld --initialize-insecure --user=mysql
[root@dns bin]# setenforce 0
[root@dns bin]# vim /etc/selinux/config sets selinux to disabled and turns off selinux.
[root@dns bin]# chown -R mysql:mysql /var/lib/mysql
[root@dns bin]# systemctl restart mysqld
Restart the mysql service successfully. You can use mysql later as needed.