wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
rpm -qa | grep mysql 如果没有文件执行下一句
rpm -qa | grep mariadb 强制卸载mariadb
可以看到一个文件
mariadb-libs-5.5.65-1.el7.x86_64
执行
rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64
tar xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar -C ./mysql -C表示制定解压到那个目录
rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm 会报错
安装四个包。包间又依赖关系。注意顺序
mysql-community-common-5.7.16-1.el7.x86_64.rpm
mysql-community-libs-5.7.16-1.el7.x86_64.rpm
mysql-community-client-5.7.16-1.el7.x86_64.rpm
mysql-community-server-5.7.16-1.el7.x86_64.rpm
rpm这四个包时还可能出现报错
rpm解压的时候会出错warning: mysql-community-server-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
这是由于yum安装了旧版本的GPG keys造成的
解决办法:后面加上
--force --nodeps
rpm安装完启动mysql
systemctl start mysqld
cat /var/log/mysqld | grep password 获取临时密码
A temporary password is generated for root@localhost: &26<mdUJY6ba
修改设置密码安全性强度
set global validate_password_length=4; //设置密码长度4位
set global validate_password_policy=0; //设置密码保护策略最低级。可以设置1234这种
重新使用临时密码登录Mysql.修改密码
alter user 'root'@'localhost' identified by 'root';
创建用户
create user 'test'@'%' identified by 'test'
权限
grant all privileges on *.* to 'test'@'%';
flush privileges;
这里注意。Mysql的配置文件目录:
vim /etc/my.cnf
修改root可支持远程登录
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
查看user的信息,先要选库 user mysql; select user,host from user;