CentOS7安装MYSQL8.X的教程详解

1.通过wget下载mysql8.0包

(如果包不是最新的则需要注意在安装MYSQL前进行Mysql的GPG升级)

[root@VM-8-4-centos local]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

2.配置mysql的yum源

[root@VM-8-4-centos local]# sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm

3.开始安装Mysql

[root@VM-8-4-centos local]# yum install -y  mysql-community-server 

注意:上面提到过,通过wget获取的MYSQL包不是最新的前提下有可能报错,这是因为MYSQL的GPG升级了,需要重新获取
如果无这个报错可忽略跳过本步骤

报错信息如下:

        Failing package is: mysql-community-client-8.0.28-1.el7.x86_64

         GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 这个时候需要重执行(2022则为今年的年份),执行完GPG升级,需要重新安装

# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
# yum install -y  mysql-community-server

4.安装完成

Installed:
  mysql-community-libs.x86_64 0:8.0.29-1.el7                mysql-community-libs-compat.x86_64 0:8.0.29-1.el7                mysql-community-server.x86_64 0:8.0.29-1.el7               

Dependency Installed:
  mysql-community-client.x86_64 0:8.0.29-1.el7                    mysql-community-client-plugins.x86_64 0:8.0.29-1.el7            mysql-community-common.x86_64 0:8.0.29-1.el7           
  mysql-community-icu-data-files.x86_64 0:8.0.29-1.el7           

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7                                                                                                                                                      

Complete!

5.启动MYSQL服务,并查看状态,并设置开机自启

[root@VM-8-4-centos local]# systemctl start mysqld   =>启动mysql
[root@VM-8-4-centos local]# systemctl status mysqld  =>查看状态
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-06-30 22:57:57 CST; 23s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 21861 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 21946 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─21946 /usr/sbin/mysqld

Jun 30 22:57:49 VM-8-4-centos systemd[1]: Starting MySQL Server...
Jun 30 22:57:57 VM-8-4-centos systemd[1]: Started MySQL Server.
[root@VM-8-4-centos local]# systemctl enable mysqld     =>开机自启

6.查看初始化密码

[root@VM-8-4-centos local]# cat /var/log/mysqld.log  | grep password
2022-06-30T14:57:52.075005Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: <FET2wpip9P7

7.登录

[root@VM-8-4-centos local]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29

Copyright (c) 2000, 2022, 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> 

8.修改密码

        在修改密码后才可以修改mysql的密码策略!

mysql> alter user 'root'@'localhost' IDENTIFIED BY '*********';
Query OK, 0 rows affected (0.02 sec)

9.修改mysql的密码策略

# 策略说明
# validate_password.length 是密码的最小长度,默认是8,我们把它改成6
mysql> set global validate_password.length=6;
# validate_password.policy 验证密码的复杂程度,我们把它改成0
mysql> set global validate_password.policy=0;
# validate_password.check_user_name 用户名检查,用户名和密码不能相同,我们也把它关掉
mysql> set global validate_password.check_user_name=off;
# 再执行修改密码的命令
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxxx';
# 密码设成功

10.设置允许远程登陆

mysql>select host, user, authentication_string, plugin from user;
mysql> update user set user.host='%'where user.user='root'; 
# MySQL8修改加密方式规则,caching_sha2_password需要改成mysql_native_password
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxx';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;                   => 刷新
Query OK, 0 rows affected (0.00 sec)

11.开放3306端口,并且重启防火墙,然后查看已放开的端口

root@VM-8-4-centos local]# firewall-cmd --zone=public --add-port=3306/tcp --permanent  
success
[root@VM-8-4-centos local]# firewall-cmd --reload
success
[root@VM-8-4-centos local]# firewall-cmd --list-ports
3306/tcp
[root@VM-8-4-centos local]# 

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用中提到了使用wget下载MySQL安装文件的步骤,但具体的wget命令没有提及。因此,可以使用以下命令来获取MySQL 5.7安装文件: ``` wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.**.tar.gz ``` 请注意,上述命令中的**需要替换为具体的版本号和文件名。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [linux wget 安装mysql5.7](https://blog.csdn.net/xiao_a_gang/article/details/82783956)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Linux:通过wget下载安装mysql数据库(5.7版本)](https://blog.csdn.net/baidu_28122193/article/details/131399488)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [(阿里云服务器)linux wget安装mysql5.7并配置远程连接](https://blog.csdn.net/m0_46229712/article/details/118945590)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值