CentOS7用YUM方式部署mysql8.0版本

5 篇文章 0 订阅

系统环境:CentOS7.9

官网下载yum仓库的包

[root@localhost ~]# wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
[root@localhost ~]# yum -y install mysql80-community-release-el7-7.noarch.rpm

进入仓库查看mysqlyum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls

##这三个就是官方mysql yum源,进入mysql-community.repo查看版本再此也可以选择版本默认是mysql8.0版本,如果要选择mysql5.7版本就把mysql8.0的enabled=1改成0,mysql5.7的enabled=0改成1然后yum makecache

[root@localhost yum.repos.d]# vim mysql-community.repo 

列出所有可安装mysql的软件包

[root@localhost ~]# yum list | grep mysql

##安装这个版本

[root@localhost ~]# yum -y install mysql-community-server.x86_64
[root@localhost ~]# systemctl enable mysqld --now 
[root@localhost ~]# netstat -anptu | grep mysql
tcp6       0      0 :::33060                :::*                    LISTEN      2866/mysqld         
tcp6       0      0 :::3306                 :::*                    LISTEN      2866/mysqld     

查看mysql默认密码
[root@localhost ~]# grep password /var/log/mysqld.log

##这是mysql安装后的默认密码,尝试登录

[root@localhost ~]# mysql -uroot -p'u?j#so_W/7+('
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

##登录成功

修改mysql默认密码

[root@localhost ~]# vim /etc/my.cnf
skip-grant-tables   ##加入这行意思是跳过权限验证的问题
[root@localhost ~]# systemctl restart mysqld

现在可以不要密码登录mysql

[root@localhost ~]# msyql -uroot
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)
mysql> use mysql;
mysql> update user set authentication_string='' where  user = 'root'; ##把root密码设置为空
mysql> flush privileges;  ##刷新权限

登出mysql进入mysql配置文件把skip-grant-tables加注释

[root@localhost ~]# vim /etc/my.cnf
#skip-grant-tables
[root@localhost ~]# systemctl restart mysqld
[root@localhost ~]# mysql -uroot
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ABc123...';
##注意mysql密码必须含有大小写字母,数字,特殊符号

尝试登录mysql

[root@localhost ~]# mysql -uroot -p'ABc123...'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

##登录成功

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

笨鸟先飞geigeigei

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

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

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

打赏作者

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

抵扣说明:

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

余额充值