热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

centos7解压缩包安装mysql8_Centos7安装MySQL8.0最新版数据库

本文将利用centos7版本系统安装MySQL8.0最新的数据库系统。在安装之前,首先要将系统做一些简单点的配置:[rootcentos7~]#cate

本文将利用centos7版本系统安装MySQL8.0最新的数据库系统。

在安装之前,首先要将系统做一些简单点的配置:

[root@centos7 ~]# cat /etc/redhat-release

CentOS Linux release 7.9.2009 (Core)

[root@centos7 ~]# uname -r

3.10.0-1160.el7.x86_64

[root@centos7 ~]# getenforce

Disabled

[root@centos7 ~]# systemctl stop firewall

[root@centos7 ~]# systemctl disable firewall1

2

3

4

5

6

7

8

因为我们是实验环境,用不到防火墙和selinux,所以我们将它关闭。1

检查一下环境,删除系统自带的MySQL相关的一切

[root@centos7 ~]# rpm -qa | grep mariadb

mariadb-libs-5.5.68-1.el7.x86_64

[root@centos7 ~]# rpm -e --nodeps mariadb-libs1

2

3

我们还需要一个MySQL的账户

[root@centos7 ~]# useradd -s /sbin/nologin -M mysql

[root@centos7 ~]# id mysql

uid=1000(mysql) gid=1000(mysql) 组=1000(mysql)1

2

3

最后的准备工作,我们需要提前安装好一些工具,为防止一会安装MySQL时候报错

[root@centos7 ~]# yum -y install gcc-c++ ncurses ncurses-devel perl bison openssl openssl-devel gcc* libxml2 libxml2-devel1

选择系统的版本

90613fd4ed0f69d7c420f15d1c18a1b1.png

选择要下载的软件包

95e6d5a3d48757aa7d87c4baf2c72521.png

然后选择下载,当然可以直接下载包在本地然后上传到centos,也可以直接下载到centos系统中,如果下载到本地,直接点击下载即可(包挺大的,建议网不好的小伙伴,可以提前准备包)

87a5f4b7a6fbc02ad05df6a181a709b1.png

为了方便,我直接利用wget命令下载到centos系统中,(养成习惯,创建一个专门存放软件包的目录)

[root@centos7 ~]# mkdir /server

[root@centos7 ~]# cd /server/

[root@centos7 server]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.23-1.el7.x86_64.rpm-bundle.tar1

2

3

将下载好的压缩包解压,并依次安装以下四个rpm包。

[root@centos7 server]# tar xf mysql-8.0.23-1.el7.x86_64.rpm-bundle.tar

[root@centos7 server]# rpm -ivh --nodeps mysql-community-common-8.0.23-1.el7.x86_64.rpm

[root@centos7 server]# rpm -ivh --nodeps mysql-community-libs-8.0.23-1.el7.x86_64.rpm

[root@centos7 server]# rpm -ivh --nodeps mysql-community-client-8.0.23-1.el7.x86_64.rpm

[root@centos7 server]# rpm -ivh --nodeps mysql-community-server-8.0.23-1.el7.x86_64.rpm1

2

3

4

5

安装成功后,进行初始化数据库

[root@centos7 server]# mysqld --initialize --user=mysql1

如果初始化成功,进入到/var/lib/mysql下,可以看到以下内容

总用量 176568

-rw-r----- 1 mysql mysql 56 2月 17 18:05 auto.cnf

-rw------- 1 mysql mysql 1676 2月 17 18:05 ca-key.pem

-rw-r--r-- 1 mysql mysql 1112 2月 17 18:05 ca.pem

-rw-r--r-- 1 mysql mysql 1112 2月 17 18:05 client-cert.pem

-rw------- 1 mysql mysql 1676 2月 17 18:05 client-key.pem

-rw-r----- 1 mysql mysql 196608 2月 17 18:05 #ib_16384_0.dblwr

-rw-r----- 1 mysql mysql 8585216 2月 17 18:05 #ib_16384_1.dblwr

-rw-r----- 1 mysql mysql 5532 2月 17 18:05 ib_buffer_pool

-rw-r----- 1 mysql mysql 12582912 2月 17 18:05 ibdata1

-rw-r----- 1 mysql mysql 50331648 2月 17 18:05 ib_logfile0

-rw-r----- 1 mysql mysql 50331648 2月 17 18:05 ib_logfile1

drwxr-x--- 2 mysql mysql 6 2月 17 18:05 #innodb_temp

drwxr-x--- 2 mysql mysql 143 2月 17 18:05 mysql

-rw-r----- 1 mysql mysql 25165824 2月 17 18:05 mysql.ibd

drwxr-x--- 2 mysql mysql 8192 2月 17 18:05 performance_schema

-rw------- 1 mysql mysql 1676 2月 17 18:05 private_key.pem

-rw-r--r-- 1 mysql mysql 452 2月 17 18:05 public_key.pem

-rw-r--r-- 1 mysql mysql 1112 2月 17 18:05 server-cert.pem

-rw------- 1 mysql mysql 1680 2月 17 18:05 server-key.pem

drwxr-x--- 2 mysql mysql 28 2月 17 18:05 sys

-rw-r----- 1 mysql mysql 16777216 2月 17 18:05 undo_001

-rw-r----- 1 mysql mysql 16777216 2月 17 18:05 undo_0021

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

而此时,MySQL数据库root账户的默认密码在/var/log/mysqld.log文件中,可以用cat查看

411e24d929c83d66812310c11c99f460.png

启动MySQL服务,并登录测试(使用日志中的默认密码)

[root@centos7 mysql]# systemctl start mysqld

[root@centos7 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.23

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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

到此,数据库安装成功,但是你会发现,此时的数据库是无法操作的,这是要求你更改密码

mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.1

2

修改MySQL的root账户密码

mysql> alter user 'root'@'localhost' identified by '123123';

Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)1

2

3

4

此时在执行SQL语句,就没有报错了

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.01 sec)1

2

3

4

5

6

7

8

9

10

至此,基于RPM文件安装MySQL的任务完成了!

文章来源: blog.csdn.net,作者:干饭的运维人,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_42527269/article/details/113835649



推荐阅读
author-avatar
phpxiaohui
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有