412 mysqld -initialize
413 groupadd mysql
414 useradd -r -g mysql -s /sbin/nologin mysql
415 chown -R mysql:mysql /var/lib/mysql
416 chmod 750 /var/lib/mysql
417 sudo -u mysql mysqld --initialize
4.启动服务 systemctl start mysqld
418 systemctl start mysqld
419 systemctl status mysqld
5.添加开机启动列表 systemctl enable mysqld
6.在 /var/log/mysqld.log中找到初始密码,前后复制空格
420 cat /var/log/mysqld.log|grep password
7.登录管理 mysql -uroot -p
8.将负责的密码粘贴到输入密码的区域,实现登录
[root@mysql ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>