下载MySQL
在MySQL官网下载相应的版本,要下载相应的版本。

安装
tar xvf mysql-8.0.26-1.el8.x86_64.rpm-bundle.tar
yun install *.rpm
初始化配置
1、启动mysql服务
systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld
2、查看MySQL密码
cat /var/log/mysqld.log | grep password

3、执行mysql_secure_installation
在执行mysql_secure_installation的时候,一定要使用【-p】参数;并且不要更改root的密码,否则可能会在重置root密码的时候导致死循环。
mysql_secure_installation -p
#一定要输入密码,由于在localhost的服务下没有设置密码,因此随意输入即可(如test)
Enter password: test
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
3、允许对外服务
默认的情况下,mysql8服务只绑定了localhost主机地址,因此不能在局域网内其他主机访问,也就更不能通过代理被其他网络使用。
vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
更改为:
bind-address = 0.0.0.0
mysqlx-bind-address = 0.0.0.0
注:其中mysqlx-bind-address是x-protocol协议服务绑定的地址,如果不需要该协议对外服务可以不进行设置。
设置后需要重新启动mysql服务
systemctl restart mysqld
创建数据库及用户
create database nacos_db;
create user nacos@'%' identified by 'Nacos@2021.';
grant all on nacos_db.* to nacos@'%';
flush privileges;