必须安装
rpm -ivh mysql-community-common-8.0.29-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-8.0.29-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-8.0.29-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-8.0.29-1.el7.x86_64.rpm --force --nodeps
非必须安装

rpm -ivh mysql-community-client-plugins-8.0.29-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-embedded-compat-8.0.29-1.el7.x86_64.rpm --force --nodeps

rpm -ivh mysql-community-libs-compat-8.0.29-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-devel-8.0.29-1.el7.x86_64.rpm --force --nodeps

rpm -ivh mysql-community-server-debug-8.0.29-1.el7.x86_64.rpm --force --nodeps

rpm -ivh mysql-community-debuginfo-8.0.29-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-icu-data-files-8.0.29-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-test-8.0.29-1.el7.x86_64.rpm  --force --nodeps



启动前修改配置文件(一定要在启动前修改)

vi /etc/my.cnf

[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4

[mysqld]
lower_case_table_names = 1
wait_timeout=120
interactive_timeout=120
character-set-server = utf8mb4
collation-server = utf8mb4_0900_ai_ci


启动
service mysqld start
如果启动失败有可能是之前安装过没有卸载清,各种奇怪的异常

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

mysqld: Table 'mysql.plugin' doesn't exist


删除遗留文件 rm -rf /var/lib/mysql 

重启启动
 
查看临时密码:
命令:cat /var/log/mysqld.log

登录

mysql -uroot -p

输入临时密码 

修改密码(这里的密码要复杂点符合密码策略)

alter user user() identified by "新密码";


//授权root远程访问
use mysql; 
update mysql.user set Host='%' where HOST='localhost' and User='root';
flush privileges;

关闭防火墙后远程登录