centos7安装mysql8.0.31版本

1. 卸载mariadb

因centos7默认安装了mariadb, 会造成依赖冲突,按下列方式进行卸载:

[root@canal ~]# 
[root@canal ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@canal ~]# 
[root@canal ~]# rpm -e mariadb-libs --nodeps
[root@canal ~]# 
[root@canal ~]# rpm -qa | grep mariadb
[root@canal ~]# 
[root@canal ~]# 

2. 下载

[root@canal ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar

[root@canal ~]# mkdir mysql-8.0.31
[root@canal ~]# 
[root@canal ~]# tar -xvf mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar -C mysql-8.0.31
mysql-community-client-8.0.31-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
mysql-community-common-8.0.31-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.31-1.el7.x86_64.rpm
mysql-community-devel-8.0.31-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.31-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.31-1.el7.x86_64.rpm
mysql-community-server-8.0.31-1.el7.x86_64.rpm
mysql-community-server-debug-8.0.31-1.el7.x86_64.rpm
mysql-community-test-8.0.31-1.el7.x86_64.rpm
[root@canal ~]# 

3. 安装

[root@canal mysql-8.0.31]# yum install -y perl.x86_64
[root@canal mysql-8.0.31]# 
[root@canal mysql-8.0.31]# rpm -ivh mysql-community-common-8.0.31-1.el7.x86_64.rpm
[root@canal mysql-8.0.31]# rpm -ivh mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
[root@canal mysql-8.0.31]# rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm
[root@canal mysql-8.0.31]# rpm -ivh mysql-community-client-8.0.31-1.el7.x86_64.rpm
[root@canal mysql-8.0.31]# rpm -ivh mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
[root@canal mysql-8.0.31]# rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm
[root@canal mysql-8.0.31]# 

4. 修改/etc/my.cnf

添加以下内容:

log_timestamps = SYSTEM

5. 启动

[root@canal mysql-8.0.31]# systemctl start mysqld
[root@canal mysql-8.0.31]# 
[root@canal mysql-8.0.31]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2022-11-18 06:59:53 CST; 1s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 1595 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 1668 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─1668 /usr/sbin/mysqld

11月 18 06:59:48 single systemd[1]: Starting MySQL Server...
11月 18 06:59:53 single systemd[1]: Started MySQL Server.
[root@canal mysql-8.0.31]# 

6. 修改密码

[root@canal mysql-8.0.31]# 
[root@canal mysql-8.0.31]# cat /var/log/mysqld.log | grep password
2022-11-18T06:59:49.967603+08:00 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: d:fAhy+G)8uw
[root@canal mysql-8.0.31]# 
[root@canal mysql-8.0.31]# mysql -u root -pd:fAhy+G\)8uw
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 8
Server version: 8.0.31

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>
mysql> alter user 'root'@'localhost' identified by 'Root_123';
Query OK, 0 rows affected (0.00 sec)

mysql> 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> select user, host from user where user='root';
+------+-----------+
| user | host      |
+------+-----------+
| root | localhost |
+------+-----------+
1 row in set (0.00 sec)

mysql> update user set host ='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.31    |
+-----------+
1 row in set (0.00 sec)

mysql>

MySQL8.0提供的授权方式采用SHA256基础的密码加密方法

  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是在 CentOS 上安装 MySQL 8.0.31 的步骤: 1. 在终端中输入以下命令,以更新您的系统并安装 MySQL 8.0.31 的依赖项: ``` sudo yum update sudo yum install wget sudo yum install curl sudo yum install libaio sudo yum install libcurl sudo yum install libstdc++6 sudo yum install libncurses5 ``` 2. 下载 MySQL 8.0.31 的 RPM 安装包: ``` wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.31-1.el8.x86_64.rpm ``` 3. 安装下载的 RPM 包: ``` sudo rpm -ivh mysql-community-server-8.0.31-1.el8.x86_64.rpm ``` 4. 启动 MySQL 服务: ``` sudo systemctl start mysqld ``` 5. 检查 MySQL 服务是否正在运行: ``` sudo systemctl status mysqld ``` 6. 如果 MySQL 服务正在运行,您应该看到以下输出: ``` ● mysqld.service - MySQL 8.0.31-1.1.el8.x86_64 Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2021-11-09 10:00:00 EST; 10s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 1234 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 5678 (mysqld) Status: "Server is operational" Tasks: 1 (limit: 512) Memory: 2.0M CGroup: /system.slice/mysqld.service └─5678 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid ``` 7. 登录到 MySQL 服务: ``` sudo mysql -u root -p ``` 8. 您将被提示输入密码。按 Enter 键,因为默认情况下 MySQL 服务没有密码。您现在可以开始使用 MySQL 8.0.31。 请注意,这只是一个基本的安装步骤,您可能需要根据您的系统和环境进行一些额外的配置。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值