CentOS7.5使用RPM包安装MySQL5.7.22和MySQL8
参考:https://blog.csdn.net/sevenkoala/article/details/76163853
1,安装环境查看
2,下载安装rpm包
下载地址:https://downloads.mysql.com/archives/community/
https://downloads.mysql.com/archives/get/file/mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
3,安装
解压
tar -xf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
解压后如下rpm安装包
清理mysql-libs
yum remove mysql-libs
安装,安装顺序为common-libs-client-server
rpm -vih mysql-community-common-5.7.22-1.el7.x86_64.rpm rpm -vih mysql-community-libs-5.7.22-1.el7.x86_64.rpm rpm -vih mysql-community-client-5.7.22-1.el7.x86_64.rpm rpm -vih mysql-community-server-5.7.22-1.el7.x86_64.rpm
启动
systemctl start mysqld systemctl status mysqld systemctl enable mysqld
查看自动生成的密码
cat /var/log/mysqld.log | grep password
登录
mysql -uroot -p'<>fd!vher73Y'
PS:如果密码有特殊字符需要用引号引起来
修改密码
set password=password('password');
2024-08-02补充开始
如果以上命令不生效使用以下命令修改密码,需要满足复杂度需求
alter user 'root'@'localhost' identified by 'Passw0$R';
2024-08-02补充结束
PS:密码需满足复杂性要求否则修改失败
关于密码复杂度导致修改密码失败解决办法参考
https://blog.csdn.net/hello_world_qwp/article/details/79551789#
2024-01-23补充安装MySQL8
如果有mariadb则先卸载否则下面安装会报错
yum remove mariadb-libs
安装顺序
rpm -ivh mysql-community-common-8.0.36-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.36-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.36-1.el7.x86_64.rpm rpm -ivh mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.36-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.36-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.36-1.el7.x86_64.rpm rpm -ivh mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm yum -y install net-tools rpm -ivh mysql-community-server-8.0.36-1.el7.x86_64.rpm systemctl start mysqld systemctl enable mysqld systemctl status mysqld