CentOS7安装MySQL8数据库

mysql下载地址:https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar

1、解压

# tar -xvf mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar
总用量 747368
-rw-r--r--. 1 7155 31415  43126424 12月 10 20:59 mysql-community-client-8.0.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415    619248 12月 10 20:59 mysql-community-common-8.0.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415   7421828 12月 10 20:59 mysql-community-devel-8.0.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415  23691824 12月 10 20:59 mysql-community-embedded-compat-8.0.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415   4212908 12月 10 20:59 mysql-community-libs-8.0.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415   1365572 12月 10 20:59 mysql-community-libs-compat-8.0.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 457272180 12月 10 21:00 mysql-community-server-8.0.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 227581052 12月 10 21:01 mysql-community-test-8.0.19-1.el7.x86_64.rpm

2、安装

2.1、安装common

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

2.2、安装libs

# rpm -ivh mysql-community-libs-8.0.19-1.el7.x86_64.rpm --nodeps --force
警告:mysql-community-libs-8.0.19-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-8.0.19-1.el7################################# [100%]

2.3、安装client

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

2.4、安装server

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

2.5、查看安装结果,是否缺失

# rpm -qa | grep mysql 
mysql-community-common-8.0.19-1.el7.x86_64
mysql-community-client-8.0.19-1.el7.x86_64
mysql-community-libs-8.0.19-1.el7.x86_64
mysql-community-server-8.0.19-1.el7.x86_64

3、MySQL配置

3.1、mysql初始化及服务配置

# mysqld --initialize;
# chown mysql:mysql /var/lib/mysql -R;
# systemctl start mysqld.service;
# systemctl  enable mysqld;

3.3、mysql密码修改

3.3.1、获取初始密码

# cat /var/log/mysqld.log | grep password
2020-04-03T03:44:00.344470Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Dosk._BIl6tE
# 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.19
Copyright © 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.

3.3.2、修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456' ;

Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
[root@poseidon1 mysql-8.0.19]# 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.19 MySQL Community Server - GPL

Copyright © 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.

3.4、远程访问的授权

mysql> create user 'root'@'%' identified with mysql_native_password by '123456';

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> grant all privileges on *.* to 'root'@'%' with grant option;

Query OK, 0 rows affected (0.01 sec)

mysql>

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye

参考文章:https://blog.csdn.net/weixin_42266606/article/details/80879571

©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页