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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值