centos8.0安装MySQL8.0

  1. cd /usr/local/
  2. mkdir mysql
  3. cd mysql
  4. 获取MySQL8.0 
  5. 把下载的MySQL8.0上传至/usr/local/mysql
  6. 第一次解压 xz -d mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
  7. 第二次解压tar xvf mysql-8.0.20-linux-glibc2.12-x86_64.tar
  8. 重命名MySQL目录mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql8.0
  9. cd mysql8.0
  10. mkdir data
  11. 创建用户组以及用户和密码
    1. groupadd mysql
    2. useradd -g mysql mysql
  12. 赋予权限chown -R mysql.mysql /usr/local/mysql/mysql8.0/
  13. 初始化信息./mysqld --user=mysql --basedir=/usr/local/mysql/mysql8.0 --datadir=/usr/local/mysql/mysql8.0/data/ --initialize
    2021-12-21T20:43:19.253428Z 0 [System] [MY-013169] [Server] /usr/local/mysql/mysql8.0/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 5416
    2021-12-21T20:43:19.271054Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2021-12-21T20:43:19.883567Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2021-12-21T20:43:20.817117Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jbhQtj3Zer=p

  14. 14中root@localhost: 后面的是临时密码,复制粘贴出来有用
  15. vi /etc/my.cnf
    #
    # This group is read both both by the client and the server
    # use it for options that affect everything
    #
    #[client-server]
    
    #
    # include all files from the config directory
    #
    !includedir /etc/my.cnf.d
    [mysqld]
    basedir=/usr/local/mysql/mysql8.0/
    datadir=/usr/local/mysql/mysql8.0/data/
    socket=/tmp/mysql.sock
    character-set-server=UTF8MB4

  16. 添加mysqld服务到系统  
    cd ..
    cp -a ./support-files/mysql.server /etc/init.d/mysql
  17. 授权以及添加服务     

    chmod +x /etc/init.d/mysql
     
    chkconfig --add mysq
     

  18. 启动MySQL systemctl start mysql 并查看状态 systemctl status mysql

  19. 将mysql命令添加到服务  ln -s /usr/local/mysql-8.0/bin/mysql /usr/bin

  20. 使用刚才复制粘贴的密码进行登录 mysql -uroot -p,但此时出现了报错显示缺少库

    mysql -uroot -p
    mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
    

  21. 将缺少的库(libtinfo.so.5)放入/usr/lib64/下,然后连接

  22. 进入MySQL后在里面执行ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysql';  其中mysql是你的新密码

  23. 在MySQL中执行使其密码生效  flush privileges;

  24. 修改数据库使你能在其他地方连接数据库

    use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> update user set host='%' where user='root';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select host,user from user;
    +-----------+------------------+
    | host      | user             |
    +-----------+------------------+
    | %         | root             |
    | localhost | mysql.infoschema |
    | localhost | mysql.session    |
    | localhost | mysql.sys        |
    +-----------+------------------+
    4 rows in set (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)
    
    

  25. 至此centos8.0安装MySQL8.0结束

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宰祖宣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值