时间:2020-10-18 14:19:50 | 栏目:Mysql | 点击:次
1 获取安装资源包 mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
链接: https://pan.baidu.com/s/1hJRNvEdOpoVf4_zNtjRaIA
提取码: rsif
2 在/usr/local目录下新建目录mysql8
cd /usr/local mkdir mysql
3 将下载的资源包(mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar)上传到 usr/local/mysql8 目录下,并解压
tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
4 rpm -qa | grep mariadb 命令查看 mariadb 的安装包5 rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps 卸载mariadb
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
6 依次安装
mysql-community-common-8.0.15-1.el7.x86_64.rpm, mysql-community-libs-8.0.18-1.el7.x86_64.rpm mysql-community-client-8.0.18-1.el7.x86_64.rpm mysql-community-server-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm
7 查看已安装资源
rpm -qa | grep mysql
8 初始化
mysqld --initialize 初始化 chown mysql:mysql /var/lib/mysql -R 授权 systemctl start mysqld 开启mysql服务 systemctl status mysqld 查看mysql 状态 cat /var/log/mysqld.log | grep password 查看root初始密码
10 使用root用户登录mysql ,并修改root用户密码
mysql -u root -p #回车之后输入前面的初始密码也就是 Iv7fjuP,ucH+(填自己的密码) ALTER USER "root"@"localhost" IDENTIFIED BY "自己的密码"; FLUSH PRIVILEGES; #立即生效
再次用户root 用户登录 输入自己刚刚修改的密码就可以了
11 远程连接
use mysql; update user set host = '%' where user ='root'; ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #更改加密方式 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '自己的密码'; #更新用户密码 (我这里为root )
连接成功
参考文章
https://www.jb51.net/article/166632.htm
https://www.jb51.net/article/141578.htm
总结