Bootstrap

centos9 安装mysql

目录

1.下载mysql安装包

2.赋值运行权限

3.安装mysql

4.检查安装情况

5.初始化

6.设置密码

6.1查看初始密码

6.2 修改密码

7 修改防火墙


1.下载mysql安装包

下载链接https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.31-1.el9.x86_64.rpm-bundle.tar

2.赋值运行权限

下载到指定的路径并赋运行权限  

 chmod -R 777 路径

3.安装mysql

需要按照顺序来安装

rpm -i mysql-community-client-plugins-8.0.31-1.el9.x86_64.rpm 

rpm -i mysql-community-common-8.0.31-1.el9.x86_64.rpm

rpm -i mysql-community-client-plugins-8.0.31-1.el9.x86_64.rpm

rpm -i mysql-community-libs-8.0.31-1.el9.x86_64.rpm

rpm -i mysql-community-client-8.0.31-1.el9.x86_64.rpm 

 rpm -i mysql-community-icu-data-files-8.0.31-1.el9.x86_64.rpm

 rpm -i mysql-community-icu-data-files-8.0.31-1.el9.x86_64.rpm

rpm -i mysql-community-server-8.0.31-1.el9.x86_64.rpm

4.检查安装情况

[root@localhost mysql-8.0.31-1.el9.x86_64.rpm-bundle]# rpm -qa | grep mysql
mysql-community-common-5.7.29-1.el7.x86_64
mysql-community-client-plugins-8.0.31-1.el9.x86_64
mysql-community-common-8.0.31-1.el9.x86_64
mysql-community-libs-8.0.31-1.el9.x86_64
mysql-community-client-8.0.31-1.el9.x86_64
mysql-community-icu-data-files-8.0.31-1.el9.x86_64
mysql-community-server-8.0.31-1.el9.x86_64

5.初始化

mysqld --initialize;  
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl  enable mysqld;

6.设置密码

6.1查看初始密码

[root@localhost mysql-8.0.31-1.el9.x86_64.rpm-bundle]# cat /var/log/mysqld.log | grep password
2022-11-30T13:34:12.944389Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Ka?krbYsz2UV

6.2 修改密码

//初始密码登录
mysql -uroot -pKa?krbYsz2UV
//修改localhost密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'XXXX';
//修改远程密码
create user 'root'@'%' identified with mysql_native_password by 'xxxx';
//刷新
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;

7 修改防火墙

  可以远程访问3306端口

firewall-cmd --zone=public --permanent --add-port=3306/tcp

systemctl start firewalld

systemctl firewall-cmd --reload

悦读

道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。 故常无欲,以观其妙,常有欲,以观其徼。 此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。

;