美文网首页
CentOS7下安装MySQL8.0.15数据库

CentOS7下安装MySQL8.0.15数据库

作者: 往后余生9375 | 来源:发表于2019-04-21 00:22 被阅读0次

    下载包

     wget http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
    

    安装源

    yum localinstall mysql80-community-release-el7-1.noarch.rpm
    

    检查源

    yum repolist enabled | grep "mysql.*-community.*"
    

    选择安装组件

    修改 vim /etc/yum.repos.d/mysql-community.repo源
    
    image.png

    安装MySQL

    shell> yum install mysql-community-server
    

    启动MySQL服务

    shell> systemctl start mysqld
    

    开机启动

    shell> systemctl enable mysqld
    shell> systemctl daemon-reload
    

    忘记密码,修复密码

    -- 忘记密码则无密码进入
    my.cnf 添加[mysqld] skip-grant-tables保存,重启
    -- 初次安装则获取密码
    grep 'temporary password' /var/log/mysqld.log
    --   清空密码
    update user set authentication_string = '' where user = 'root';
    mysql -uroot -p
    -- 重新设置新的root密码
     ALTER USER 'root'@'localhost' IDENTIFIED BY'你的密码';
    -- 修改host为匹配所有
    update user set host="%" where user='root';
    -- 配置外网访问
    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY'51//Hengyi';
    -- 刷新
     flush privileges;
    

    配置远程访问

    create user '你的账号'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码.';
    grant all privileges on *.* to 账号@'%' with grant option;
    //或
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Admin123!' WITH GRANT OPTION;
    flush privileges;
    

    修复数据库

    mysql -u root -p
    mysql> SET GLOBAL innodb_fast_shutdown = 1;
    mysql_upgrade -u root -p
    

    卸载MySQL8.0

    yum remove mysql-community-server
    rpm -qa | grep mysql
    yum remove mysql*
    

    相关文章

      网友评论

          本文标题:CentOS7下安装MySQL8.0.15数据库

          本文链接:https://www.haomeiwen.com/subject/rtorgqtx.html