rocky linux:yum方式安装mysql 8( mysql 8.0.33 / Rocky Linux 9.1)
一,安装mysql的release包
1,官网:
https://www.mysql.com/
如图:
2,下载
也可以获取链接后在linux上wget
[root@img mysql]# wget https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
安装rpm包
[root@img mysql]# rpm -ivh mysql80-community-release-el9-1.noarch.rpm
warning: mysql80-community-release-el9-1.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql80-community-release-el9-1 ################################# [100%]
查看yum的源,是否已添加了mysql
[root@img mysql]# yum repolist enabled
如图:
二,安装mysql
1,yum安装
[root@img mysql]# yum install -y mysql-community-server
2,查看已安装的软件包:
[root@img mysql]# rpm -qa | grep mysql
mysql80-community-release-el9-1.noarch
mysql-community-common-8.0.33-1.el9.x86_64
mysql-community-client-plugins-8.0.33-1.el9.x86_64
mysql-community-libs-8.0.33-1.el9.x86_64
mysql-community-client-8.0.33-1.el9.x86_64
mysql-community-icu-data-files-8.0.33-1.el9.x86_64
mysql-community-server-8.0.33-1.el9.x86_64
三,启动mysql服务:
1,启动
[root@img mysql]# systemctl start mysqld.service
2,查看状态
[root@img mysql]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (;;file://img/usr/lib/systemd/system/mysqld.service/usr/lib/systemd/system/mysqld.service;;; enabled; vendor preset: disabled)
Active: active (running) since Thu 2023-05-11 19:42:30 CST; 6s ago
Docs: ;;man:mysqld(8)man:mysqld(8);;
;;http://dev.mysql.com/doc/refman/en/using-systemd.htmlhttp://dev.mysql.com/doc/refman/en/using-systemd.html;;
Process: 355211 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 355282 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 47185)
Memory: 482.2M
CPU: 3.961s
CGroup: /system.slice/mysqld.service
└─355282 /usr/sbin/mysqld
May 11 19:42:24 img systemd[1]: Starting MySQL Server...
May 11 19:42:30 img systemd[1]: Started MySQL Server.
3,设置为开始自启动:
[root@img mysql]# systemctl enable mysqld.service
四,登录,并重置密码
1,得到临时密码:
[root@img mysql]# grep password /var/log/mysqld.log
2023-05-11T11:42:27.645077Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Ua7bcdJez(vQ
2,用临时密码登录:
可以看到登录后要求重置密码,而在重置密码前禁止其他操作
3,重置密码:
说明:
默认密码策略要求密码至少包含一个大写字母、一个小写字母、一位数字和一个特殊字符,
并且密码总长度至少为8个字符
mysql> alter user 'root'@'localhost' identified by "123456";
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by "Demo12345!";
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
五,查看mysql的版本:
[root@img mysql]# /usr/sbin/mysqld -V
/usr/sbin/mysqld Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)
说明:刘宏缔的架构森林是一个专注架构的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/06/06/rocky-linux-yum-fang-shi-an-zhuang-mysql-8-mysql-8-33/
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
六,查看linux的版本:
[root@img mysql]# cat /etc/redhat-release
Rocky Linux release 9.1 (Blue Onyx)