RockyLinux 9.4下安装 下载地址:MySQL Community Downloads
我下载的是MySQL Yum Repository 。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 rpm -ivh mysql84-community-release-el9-1.noarch.rpm dnf makecache dnf install -y mysql-community-server-8.4.2-1.el9.x86_64 systemctl enable mysqld.service firewall-cmd --permanent --zone=public --add-port=3306/tcp systemctl restart firewalld.service
my.cnf 文件简单配置【文件路径 /etc/my.cnf
】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [mysqld ] bind-address=0.0.0.0 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci default-storage-engine=INNODB mysql_native_password=ON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 systemctl start mysqld.service [root@kelvyn ~]# systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled) Active: active (running) since Fri 2024-09-13 19:13:13 CST; 10min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Main PID: 1368 (mysqld) Status: "Server is operational" Tasks: 34 (limit : 23036) Memory: 520.9M CPU: 2.634s CGroup: /system.slice/mysqld.service └─1368 /usr/sbin/mysqld Sep 13 19:13:07 kelvyn systemd[1]: Starting MySQL Server... Sep 13 19:13:13 kelvyn systemd[1]: Started MySQL Server.
配置MySQL远程登录 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 grep "password is generated" /var/log/mysqld.log | awk '{print $NF}' mysql -uroot -p ALTER USER 'root' @'localhost' IDENTIFIED BY 'Meng.Kelvyn123' ; show global variables like '%validate_password%' ; set global validate_password.policy=0; set global validate_password.length=4; ALTER USER 'root' @'localhost' IDENTIFIED BY '123456' ; USE mysql; update user set host = '%' where user = 'root' ; flush privileges;
这次通过Navicat等软件就可以直接连接了。