MySQL

Woodrow讨论 | 贡献2022年3月30日 (三) 22:15的版本 (建立内容为“== MySQL Community Server == https://downloads.mysql.com/archives/community/ == 卸载MariaDB == <syntaxhighlight lang="bash"> rpm -qa | grep -i mariadb rpm -e m…”的新页面)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

MySQL Community Server

https://downloads.mysql.com/archives/community/

卸载MariaDB

rpm -qa | grep -i mariadb
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps

创建目录、解压

mkdir mysql
tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar -C mysql

安装MySQL

cd mysql
rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
yum install openssl-devel
rpm -ivh mysql-community-devel-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm

启动MySQL服务

systemctl start mysqld

查询自动生成的root用户密码

grep 'temporary password' /var/log/mysqld.log
mysql -u root -p

修改root用户密码

set global validate_password.policy = 0;
set global validate_password.length = 8;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

创建用户

CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

授予权限

GRANT ALL ON *.* TO 'root'@'%';

重新连接MySQL

mysql -u root -p