centos安装mysql8.0.13_CentOS7.5 rpm方式安装MySQL8.0.13

Linux版本:CentOS7.5

MySQL版本:8.0.13

1、下载MySQL8

下载地址:https://downloads.mysql.com/archives/community/

mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar

选择版本和系统版本,然后Download。

2、安装MySQL8

登陆root用户。上传安装包到服务器(或者可以在服务器直接使用wget命令进行下载),并解压。

卸载mariadb,会与MySQL安装冲突。

rpm -qa | grep mariadb查看有无mariadb

[root@localhost tools]# ll

total 683252

-rw-r--r--. 1 root root 167741674 Nov 16  2016 jdk-8u112-linux-x64.rpm

-rw-r--r--. 1 root root 531906560 May  8 04:42 mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar

[root@localhost tools]# rpm -qa | grep mariadb

mariadb-libs-5.5.56-2.el7.x86_64

如果有则删除yum -y remove mariadb-libs.x86_64

[root@localhost tools]# yum -y remove mariadb-libs-5.5.56-2.el7.x86_64

[root@localhost tools]# rpm -qa | grep mariadb

3、安装numactl

yum list installed|grep numactl

如果没有则yum install numactl,否则会在安装时报错

error:

Failed dependencies:

libnuma.so.1()(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64

libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64

libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64

[root@localhost tools]# yum list installed|grep numactl

numactl-libs.x86_64                   2.0.9-7.el7                      @anaconda

[root@localhost tools]# yum install numactl

[root@localhost tools]# yum list installed|grep numactl

numactl.x86_64                        2.0.12-5.el7                     @base

numactl-libs.x86_64                   2.0.9-7.el7                      @anaconda

[root@localhost tools]#

4、解压tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar

安装4个必须安装的包(需要按顺序安装)。

rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.13-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm

[root@localhost tools]# tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar

安装依赖包

yum -y install net-tools openssl-devel.x86_64 openssl.x86_64  perl* perl.x86_64 perl-devel.x86_64  perl-JSON.noarch

[root@localhost tools]# ls

jdk-8u112-linux-x64.rpm

mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar

mysql-community-client-8.0.13-1.el7.x86_64.rpm

mysql-community-common-8.0.13-1.el7.x86_64.rpm

mysql-community-devel-8.0.13-1.el7.x86_64.rpm

mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm

mysql-community-libs-8.0.13-1.el7.x86_64.rpm

mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm

mysql-community-server-8.0.13-1.el7.x86_64.rpm

mysql-community-test-8.0.13-1.el7.x86_64.rpm

[root@localhost tools]# rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-common-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-common-8.0.13-1.e################################# [100%]

[root@localhost tools]# rpm -ivh mysql-community-libs-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-libs-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-libs-8.0.13-1.el7################################# [100%]

[root@localhost tools]# rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-client-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-client-8.0.13-1.e################################# [100%]

[root@localhost tools]# rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-server-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-server-8.0.13-1.e################################# [100%]

[root@localhost tools]#

5、安装另外4个非必须包(需要按顺序安装也可以不装跳过此步骤)。

rpm -ivh mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm

rpm -ivh mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm

rpm -ivh mysql-community-devel-8.0.13-1.el7.x86_64.rpm

rpm -ivh mysql-community-test-8.0.13-1.el7.x86_64.rpm

[root@localhost tools]# rpm -ivh mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-libs-compat-8.0.1################################# [100%]

[root@localhost tools]# rpm -ivh mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-embedded-compat-8################################# [100%]

[root@localhost tools]# rpm -ivh mysql-community-devel-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-devel-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-devel-8.0.13-1.el################################# [100%]

[root@localhost tools]# rpm -ivh mysql-community-test-8.0.13-1.el7.x86_64.rpm

warning: mysql-community-test-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-test-8.0.13-1.el7################################# [100%]

[root@localhost tools]#

6.初始化数据库

[root@localhost tools]# mysqld --initialize --console

7.目录授权,否则启动失败

[root@localhost tools]# chown -R mysql:mysql /var/lib/mysql/

8.启动msyql服务

root@localhost tools]# systemctl start mysqld

备注:

停止命令:service mysqld stop

9.查看msyql服务的状态

[root@localhost tools]# service mysqld status

Redirecting to /bin/systemctl status mysqld.service

â— mysqld.service - MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: active (running) since Fri 2020-05-08 21:57:41 EDT; 40s ago

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

Process: 4372 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

Main PID: 4390 (mysqld)

Status: "SERVER_OPERATING"

Tasks: 38

CGroup: /system.slice/mysqld.service

└─4390 /usr/sbin/mysqld

May 08 21:57:40 localhost.localdomain systemd[1]: Starting MySQL Server...

May 08 21:57:41 localhost.localdomain systemd[1]: Started MySQL Server.

[root@localhost tools]#

10、登陆MySQL8

查看临时密码 cat /var/log/mysqld.log

[root@localhost tools]# cat /var/log/mysqld.log

2020-05-09T01:50:58.461277Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server in progress as process 3987

2020-05-09T01:51:00.295152Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: :Lyqf3Q!FdZa

2020-05-09T01:51:01.339296Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server has completed

2020-05-09T01:57:41.374276Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.13) starting as process 4390

2020-05-09T01:57:41.921385Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2020-05-09T01:57:41.993878Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.13'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.

2020-05-09T01:57:42.055552Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

[root@localhost tools]#

使用临时密码登陆并修改密码。

mysql -u root -p回车输入临时密码。

alter USER 'root'@'localhost' IDENTIFIED BY '新密码(必须包含:数字大小写字母特殊字符)';

[root@localhost tools]# mysql -u root -p

Enter password:        :Lyqf3Q!FdZa

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 11

Server version: 8.0.13

Copyright (c) 2000, 2018, 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> alter USER 'root'@'localhost' IDENTIFIED BY 'Zkm!@123';

Query OK, 0 rows affected (0.09 sec)

修改MySQL的root用户远程可以登陆

use mysql;

select host, user from user;

如果host为localhost则执行 update user set host = "%" where user='root';

刷新生效flush privileges;

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 host,user from user;

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

| host      | user             |

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

| localhost | mysql.infoschema |

| localhost | mysql.session    |

| localhost | mysql.sys        |

| localhost | root             |

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

4 rows in set (0.00 sec)

mysql> update user set host = "%" where user='root';

Query OK, 1 row affected (0.10 sec)

Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql>

解决部分客户端无法连接的问题,比如dbvisualizer报

Unable to load authentication plugin 'caching_sha2_password

mysql -u root -p回车输入密码。

alter USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root用户的密码';

刷新生效flush privileges;

mysql> quit

Bye

[root@localhost tools]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 15

Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, 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> alter USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Zkm!@123';

Query OK, 0 rows affected (0.04 sec)

mysql> flush privileges;

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 host,user from user;

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

| host      | user             |

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

| %         | root             |

| localhost | mysql.infoschema |

| localhost | mysql.session    |

| localhost | mysql.sys        |

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

4 rows in set (0.00 sec)

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| sys                |

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

4 rows in set (0.00 sec)

mysql> quit

Bye

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值