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

原创 健旺  2018-05-13 16:40  阅读 3,499 次

卸载MariaDB

  1. 列出所有被安装的rpm package
    [root@centos ~]# rpm -qa | grep mariadb 
    mariadb-libs-5.5.56-2.el7.x86_64
    
  2. 强制卸载
    [root@centos ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
    

安装MySQL

  1. 下载MySQL源(后缀是noarch.rpm)
    [root@centos ~]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
    
  2. 安装mysql源
    [root@centos ~]# yum localinstall mysql80-community-release-el7-1.noarch.rpm 
    
  3. 检查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 
    
  4. 安装MySQL
    [root@centos ~]# yum install mysql-community-server
    

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

  5. 启动MySQL服务

    [root@centos ~]# systemctl start mysqld
    
  6. 查看MySQL的启动状态
    [root@centos ~]# systemctl status mysqld
    
  7. 找出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
    
  8. 使用数据库root用户登录
    [root@centos ~]# mysql -u root -p 
    Enter password:  &/hQlEZXc1gT
    
  9. 修改默认密码
    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

  10. 远程连接授权

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

    重启MySQL

    [root@centos ~]# systemctl restart mysqld;
    
  11. 开放3306端口
    [root@centos ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
    [root@centos ~]# firewall-cmd --reload
    

参考:http://www.cnblogs.com/wangdaijun/p/8530087.html

本文地址:http://www.256it.com/110.html
版权声明:本文为原创文章,版权归 健旺 所有,欢迎分享本文,转载请保留出处!
PREVIOUS:已经是最后一篇了
相关文章 关键词:

发表评论


表情