安装MySQL数据库
更换yum源
安装
yum install wget -y
将系统原始配置文件失效
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
使用阿里的配置源
wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清空以前yum源的缓存
yum clean all
获取阿里云的缓存
yum makecache
安装MySQL
安装Mysql依赖 perl net-tools
yum install perl net-tools -y
卸载mariadb
查看自带的mariadb版本
rpm -qa | grep mariadb
卸载命令,后面卸载那个版本是你上个命令查询出来的
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
解压mysql压缩包
tar -xvf mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar
首先安装 common
rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm
其次安装 client
rpm -ivh mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
再安装 libs
rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm
接下来安装 client
rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm
最后安装 server
rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
当出现错误或者重复安装的情况 后面加 --force --nodep 没有错误忽略这句话
例如 rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm --force --nodep
启动mysql
systemctl start mysqld
查找密码并登陆Mysql
cat /var/log/mysqld.log | grep password
登录Mysql
mysql -u root -p
修改mysql默认的密码 以8版本Mysql为准
set global validate_password.policy=LOW;
set global validate_password.length=6;
更改加密方式
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’ PASSWORD EXPIRE NEVER;
更新用户密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘123456’;
刷新权限
FLUSH PRIVILEGES;
修改MySql链接地址
use mysql;
update user set host=’%’ where user = ‘root’;
提交
commit;
退出
exit;
重启
systemctl restart mysqld;
关闭防火墙使用Navicat访问即可