Centos 离线安装mysql8(以及在线安装)

1、准备阶段

  • 去官网下载tar包
    下载地址: https://dev.mysql.com/downloads/mysql/

  • 选择适应的版本(根据自己系统选择合适的版本)

  • 直接下载

  • 清处主机上的环境
    [root@node2 ~]# rpm -qa|grep mariadb
    mariadb-libs-5.5.64-1.el7.x86_64
    [root@node2 ~]# rpm -e --nodeps mariadb-libs

  • 将包上传并解压

2、安装

1、依次安装

mysql-community-common-8.0.21-1.el7.x86_64.rpm
mysql-community-libs-8.0.21-1.el7.x86_64.rpm
mysql-community-client-8.0.21-1.el7.x86_64.rpm
mysql-community-server-8.0.21-1.el7.x86_64.rpm

3、启停服务

1、[root@node2 mysql]# systemctl status mysqld

2、停止服务[root@node2 mysql]# systemctl stop mysqld
3、初始化数据库mysqld --initialize --console

4、目录授权chown -R mysql:mysql /var/lib/mysql/
5、启动服务[root@node2 mysql]# systemctl start mysqld

3、数据使用

1、查看临时密码
[root@node2 mysql]# cat /var/log/mysqld.log | grep password
2、用临时密码登录数据库

命令:mysql -u root -p 回车键

然后输入临时密码(输入时不会显示出来,输入完直接回车)
3、修改密码
命令:alter USER 'root'@'localhost' IDENTIFIED BY '123456';
4、授权远程连接

命令:show databases;

命令:use mysql;

命令:select host, user, authentication_string, plugin from user;
命令:update user set host = "%" where user='root';

命令:select host, user, authentication_string, plugin from user;

命令:flush privileges;

4、修改密码规则
update user set plugin='mysql_native_password' where user ='root';
alter USER 'root'@'%' IDENTIFIED BY '123456';

转自:https://www.cnblogs.com/quchunhui/p/11115339.html

二、在线安装mysql

参考如下链接:
https://www.cnblogs.com/wlwl/p/9686809.html

三、centos8在线安装mysql8
参考二,安装命令更改为

dnf install @mysql
systemctl enable --now mysqld
systemctl status mysqld

后续改密操作跟其他相似

posted @ 2020-08-16 23:44  菜鸟成长历程  阅读(2242)  评论(0编辑  收藏  举报