CentOS7.5下yum安装MySQL8.0.11笔记

**参考:**

卸载MariaDB

列出所有被安装的rpm package

[root@centos ~]# rpm -qa | grep mariadb mariadb-libs-5.5.56-2.el7.x86_64

强制卸载

[root@centos ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

安装MySQL

下载MySQL源(后缀是noarch.rpm)

[root@centos ~]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

安装mysql源

[root@centos ~]# yum localinstall mysql80-community-release-el7-1.noarch.rpm

检查mysql源是否安装成功

[root@centos ~]# yum repolist enabled | grep "mysql.*-community.*"

出现如下所示表示安装成功:

mysql-connectors-community/x86_64 MySQL Connectors Community 51 mysql-tools-community/x86_64 MySQL Tools Community 63 mysql80-community/x86_64 MySQL 8.0 Community Server 17

安装MySQL

[root@centos ~]# yum install mysql-community-server

出现Error downloading packages:错误,重复执行上述命令。

启动MySQL服务

[root@centos ~]# systemctl start mysqld

查看MySQL的启动状态

[root@centos ~]# systemctl status mysqld

找出root默认密码

mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改。

[root@centos ~]# grep 'temporary password' /var/log/mysqld.log 2018-05-13T02:02:14.879263Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: &/hQlEZXc1gT

使用数据库root用户登录

[root@centos ~]# mysql -u root -p Enter password: &/hQlEZXc1gT

修改默认密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql&123456789'; mysql> flush privileges;

注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000)错误,如下图所示:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456789';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

远程连接授权

mysql> use mysql; mysql> select user,host from user; mysql> update user set host = '%' where user = 'root';

重启MySQL

[root@centos ~]# systemctl restart mysqld;

开放3306端口

[root@centos ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp [root@centos ~]# firewall-cmd --reload

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpxxsg.html