1 去官网下载安装包
https://dev.mysql.com/downloads/mysql/
镜像:
http://mirrors.sohu.com/mysql/
http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/
2 需将系统自带的mariadb-lib卸载
rpm -qa|grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
2 解压安装包
tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
3 使用rpm -ivh命令依次进行安装
注意,按照common–>libs–>client–>server的顺序,安装server的时候需要依赖libaio库文件
yum install libaio
rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm ( --force --nodeps)
rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
...
4 启动数据库
// 启动数据库
systemctl start mysqld
// 查看状态
systemctl status mysqld
5 使用初始密码登录
初始密码通过
cat /var/log/mysqld.log | grep password
查看
mysql -uroot -p密码
6 修改密码和安全级别
// 设置安全级别:0最低,1中级,2最强
set global validate_password_policy=0;
// 设置密码
set password for root@localhost = password( '123456' );
7 授权远程访问
grant all privileges on *.* to 'root'@'%' IDENTIFIED BY 'password';
网友评论