微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CentOS7版本如何安装Mysql8.0.20版本数据库

小编这次要给大家分享的是CentOS7版本如何安装Mysql8.0.20版本数据库文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。

CentOS7安装MysqL8.0.20步骤:

https://dev.MysqL.com/doc/relnotes/MysqL/8.0/en/news-8-0-20.html

官网下载有时速度比较慢,直接点击链接也可以下载:MysqL 8.0.20

官网下载8.0.20MysqL包(bundle版本)

1.创建MysqL文件夹:

[root@localhost ~]# mkdir /usr/local/MysqL
[root@localhost ~]# cd /usr/local/MysqL/

将下载的MysqL包放在创建的MysqL文件夹内:

[root@localhost MysqL]# ll
总用量 815000
-rw-r--r--. 1 root root 834560000 5月 13 10:44 mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar

MysqL的安装版MD5码查看是否和官网上的相对应:

[root@localhost MysqL]# md5sum mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar 
c8d062c1f74d9aab7dbdd5300b202b6e mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar

MysqL的包解压得到几个内安装包:

[root@localhost MysqL]# 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@localhost MysqL]# ll
总用量 1630004
-rw-r--r--. 1 root root 834560000 5月 13 10:44 mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415 48822048 3月 27 20:14 MysqL-community-client-8.0.20-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 623508 3月 27 20:14 MysqL-community-common-8.0.20-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 8129988 3月 27 20:14 MysqL-community-devel-8.0.20-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 23599996 3月 27 20:14 MysqL-community-embedded-compat-8.0.20-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 4667884 3月 27 20:14 MysqL-community-libs-8.0.20-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 1277128 3月 27 20:14 MysqL-community-libs-compat-8.0.20-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 512057468 3月 27 20:15 MysqL-community-server-8.0.20-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 235369940 3月 27 20:16 MysqL-community-test-8.0.20-1.el7.x86_64.rpm

依次安装顺序时common,libs,libs-compat,client,server:

警告:MysqL-community-common-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY
准备中...  ################################# [100%]
正在升级/安装...
 1:MysqL-community-common-8.0.20-1.e################################# [100%]
警告:MysqL-community-libs-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY
准备中...  ################################# [100%]
正在升级/安装...
 1:MysqL-community-libs-8.0.20-1.el7################################# [100%]
警告:MysqL-community-libs-compat-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY
准备中...  ################################# [100%]
正在升级/安装...
 1:MysqL-community-libs-compat-8.0.2################################# [100%]
警告:MysqL-community-client-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY
准备中...  ################################# [100%]
正在升级/安装...
 1:MysqL-community-client-8.0.20-1.e################################# [100%]
警告:MysqL-community-server-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY
准备中...  ################################# [100%]
正在升级/安装...
 1:MysqL-community-server-8.0.20-1.e################################# [100%]

编辑一下/etc/my.cnf文件
在最下面增加一行:

lower_case_table_names=1

initialize初始化:

[root@localhost MysqL]# MysqLd --initialize
[root@localhost MysqL]#

更改一下权限:

[root@localhost MysqL]# chown -R MysqL:MysqL /var/lib/MysqL
[root@localhost MysqL]# ll /var/lib/
总用量 8
drwxr-xr-x. 4 root root 32 5月 13 10:07 AccountsService
drwxr-xr-x. 2 root root 6 8月 3 2017 alsa
drwxr-xr-x. 2 root root 274 5月 13 10:14 alternatives
drwx------. 3 root root 18 5月 13 10:17 authconfig
drwxr-xr-x. 2 root root 6 8月 3 2017 bluetooth
drwxr-xr-x. 2 chrony chrony 6 8月 4 2017 chrony
drwxr-xr-x. 3 root root 17 5月 13 10:06 color
drwxr-xr-x. 4 colord colord 67 5月 13 10:23 colord
drwxr-xr-x. 2 root root 6 11月 7 2016 dbus
drwxr-xr-x. 2 root root 6 8月 4 2017 dhclient
drwxr-xr-x. 2 root root 6 8月 3 2017 dnsmasq
drwxr-xr-x. 3 root root 34 5月 13 10:24 flatpak
drwxr-xr-x. 2 root root 6 6月 24 2014 fprint
drwxr-xr-x. 2 root root 6 11月 5 2016 games
drwxrwx--T. 5 gdm gdm 70 5月 13 10:23 gdm
drwxr-xr-x. 2 geoclue geoclue 6 8月 2 2017 geoclue
drwxr-xr-x. 4 root root 55 5月 13 02:22 gssproxy
drwxr-xr-x. 2 root root 6 8月 2 2017 hyperv
drwxr-xr-x. 2 root root 6 8月 5 2017 initramfs
drwxr-xr-x. 8 root root 90 5月 13 10:07 iscsi
drwxr-xr-x. 8 root root 93 5月 13 10:08 libvirt
drwxr-xr-x. 2 root root 6 11月 6 2016 lldpad
drwxr-xr-x. 2 root root 6 8月 2 2017 logrotate
drwx------. 2 root root 6 5月 13 10:06 machines
drwxr-xr-x. 2 root root 37 5月 13 02:22 misc
drwxr-x---. 2 root slocate 6 11月 5 2016 mlocate
drwxr-x--x. 6 MysqL MysqL 4096 5月 13 11:05 MysqL

启动MysqL服务看一下服务状态,看Active这一行的状态:

[root@localhost MysqL]# systemctl start MysqLd.service 
[root@localhost 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-05-13 11:09:35 CST; 8s ago
 Docs: man:MysqLd(8)
 http://dev.MysqL.com/doc/refman/en/using-systemd.html
 Process: 16795 ExecStartPre=/usr/bin/MysqLd_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 16829 (MysqLd)
 Status: "Server is operational"
 CGroup: /system.slice/MysqLd.service
 └─16829 /usr/sbin/MysqLd

5月 13 11:09:24 localhost.localdomain systemd[1]: Starting MysqL Server...
5月 13 11:09:35 localhost.localdomain systemd[1]: Started MysqL Server.
[root@localhost MysqL]#

查看数据库初始的密码:

[root@localhost MysqL]# cat /var/log/MysqLd.log | grep password
2020-05-13T03:05:16.041238Z 6 [Note] [MY-010454] 
[Server] A temporary password is generated for root@localhost: n_t#tk.Z?7)f

使用初始密码登陆数据库:后更改密码:

[root@localhost MysqL]# 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.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>
MysqL> ALTER user 'root'@'localhost' identified with MysqL_native_password by '123456';
Query OK, 0 rows affected (0.04 sec)

MysqL> exit
Bye
[root@localhost 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 MysqL Community Server - GPL

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> SELECT VERSION;
ERROR 1054 (42S22): UnkNown column 'VERSION' in 'field list'
MysqL> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.20 |
+-----------+
1 row in set (0.00 sec)

MysqL>

到此可以正常登陆数据库了,可以自行查找开启远程方式。

看完这篇关于CentOS7版本如何安装MysqL8.0.20版本数据库文章,如果觉得文章内容写得不错的话,可以把它分享出去给更多人看到。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐