检查是否安装了Mariadb(把我害苦了)
rpm -qa|grep mariadb
删除Mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
下载mysql 5.7.34
1、wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-common-5.7.35-1.el7.x86_64.rpm
2、wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-client-5.7.35-1.el7.x86_64.rpm
3、wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-libs-5.7.35-1.el7.x86_64.rpm
4、wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-server-5.7.34-1.el7.x86_64.rpm
或 wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-server-5.7.35-1.el7.x86_64.rpm
安装命令
1、sudo rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm
2、sudo rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm
3、sudo rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm
4、sudo rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
--nodeps:不检查依赖关系
--force:强制安装
注
为什么不用yum -y install mysql-community-server-5.7.34-1.el7.x86_64.rpm
因为报错:
错误:软件包:mysql-community-server-5.7.34-1.el7.x86_64 (/mysql-community-server-5.7.34-1.el7.x86_64)
需要:mysql-community-client(x86-64) >= 5.7.9
错误:软件包:mysql-community-server-5.7.34-1.el7.x86_64 (/mysql-community-server-5.7.34-1.el7.x86_64)
需要:mysql-community-common(x86-64) = 5.7.34-1.el7
配置
修改默认密码
vim /etc/my.cnf
在文件末尾添加 skip-grant-tables
启动mysql
systemctl start mysqld
登录
mysql -u root -p
use information_schema
update mysql.user set authentication_string=password('你的密码') where user='用户';
exit
修改密码
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
设置开机启动
systemctl enable mysqld
设置密码复杂度
SHOW VARIABLES LIKE 'validate_password%';
set global validate_password_length=6;
开启mysql的远程访问
grant all privileges on . to 'root'@'192.168.0.1' identified by 'password' with grant option;
创建用户
flush privileges;
CREATE USER 'admin'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON . TO 'admin'@'%' WITH GRANT OPTION;
将字符限制修改为全小写
lower_case_table_names=1
卸载Mysql
rpm -qa|grep -i mysql #查看已经安装的mysql组件
rpm -ev --nodeps mysql-community-server-5.7.35-1.el7.x86_64 # 卸载组件