CentOS 7 傻瓜式安装 MySQL 8.0+ 版本数据库(8.0.20)

1. 从MySQL官网,下载MySQL所需要的安装包。

 网址:https://dev.mysql.com/downloads/mysql/
 
 Select Operating System: 选择 Red Hat(因为CentOS 是基于红帽的);Select OS Version: 选择 linux 7

 下载第一个: mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar

在这里插入图片描述

2. 点击 No thanks, just start my download. 进行下载,cp到虚拟机里

 [root@zw ~]# cd /opt
[root@zw opt]# ls
mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar

3. 通过tar 解压

[root@zw opt]# tar -xvf  mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar 
mysql-community-libs-8.0.20-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpm
mysql-community-test-8.0.20-1.el7.x86_64.rpm
mysql-community-common-8.0.20-1.el7.x86_64.rpm
mysql-community-devel-8.0.20-1.el7.x86_64.rpm
mysql-community-client-8.0.20-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm
mysql-community-server-8.0.20-1.el7.x86_64.rpm

[root@zw opt]# ls
mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar        mysql-community-devel-8.0.20-1.el7.x86_64.rpm            mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm
mysql-community-client-8.0.20-1.el7.x86_64.rpm  mysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpm  mysql-community-server-8.0.20-1.el7.x86_64.rpm
mysql-community-common-8.0.20-1.el7.x86_64.rpm  mysql-community-libs-8.0.20-1.el7.x86_64.rpm             mysql-community-test-8.0.20-1.el7.x86_64.rpm

4、通过 rpm -ivh 安装

[root@zw opt]# rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm --nodeps --force
警告:mysql-community-common-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-common-8.0.20-1.e################################# [100%]
[root@zw opt]# rpm -ivh mysql-community-c --nodeps --force
mysql-community-client-8.0.20-1.el7.x86_64.rpm  mysql-community-common-8.0.20-1.el7.x86_64.rpm  
[root@zw opt]# rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm --nodeps --force
警告:mysql-community-client-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-8.0.20-1.e################################# [100%]
[root@zw opt]# rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm --nodeps --force
警告:mysql-community-server-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-server-8.0.20-1.e################################# [100%]

5. 通过以下命令,完成对 mysql 数据库的初始化和相关配置

[root@zw opt]# mysqld --initialize
[root@zw mysql]# chown mysql:mysql /var/lib/mysql -R
[root@zw mysql]# systemctl start mysqld.service
[root@zw mysql]# systemctl status  mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 一 2020-06-08 17:32:33 CST; 26s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 22395 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 22445 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─22445 /usr/sbin/mysqld

6月 08 17:32:02 zw systemd[1]: Starting MySQL Server...
6月 08 17:32:33 zw systemd[1]: Started MySQL Server.

6. 查看日志获取初始密码,连接mysql修改初始密码

[root@zw ~]#  grep password /var/log/mysqld.log
2020-06-08T09:30:18.510275Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pu4pj6bIBZ&g

[root@zw mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.20

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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>

7.修改root,并开启远程访问(修改密码为Welljoint,123)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Welljoint,123';
Query OK, 0 rows affected (0.05 sec)

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

mysql> create user 'root'@'%' identified with mysql_native_password by 'Welljoint,123'; #开启远程登录授权
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.05 sec)

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

mysql> exit
Bye

8. Navicat使用 连接测试

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值