CentOS   发布时间:2022-05-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了centos7.3 安装mysql5.7.18的详细教程大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

1查看Linux发行版本

[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (CorE)

2 下载MysqL官方的Yum Repository

根据Linux发行版本(CentOS、Fedora都属于红帽系),从MysqL官方(http://dev.mysql.com/downloads/repo/yum/)获取Yum Repository。

[root@typecodes ~]# wget -i http://dev.Mysql.com/get/MysqL57-community-release-el7-7.noarch.rpm
--2016-02-03 18:36:02-- http://dev.Mysql.com/get/MysqL57-community-release-el7-7.noarch.rpm
Resolving dev.Mysql.com (dev.Mysql.com)... 137.254.60.11
ConnecTing to dev.Mysql.com (dev.Mysql.com)|137.254.60.11|:80... connected.
http request sent,awaiTing response... 302 Found
LOCATIOn: http://repo.Mysql.com//MysqL57-community-release-el7-7.noarch.rpm [following]
--2016-02-03 18:36:04-- http://repo.Mysql.com//MysqL57-community-release-el7-7.noarch.rpm
Resolving repo.Mysql.com (repo.Mysql.com)... 104.102.164.25
ConnecTing to repo.Mysql.com (repo.Mysql.com)|104.102.164.25|:80... connected.
http request sent,awaiTing response... 200 OK
Length: 8984 (8.8K) [application/x-redhat-package-manager]
Saving to: ‘MysqL57-community-release-el7-7.noarch.rpm'
100%[=============================================================================================================================>] 8,984  --.-K/s in 0s
2016-02-03 18:36:07 (68.4 MB/s) - ‘MysqL57-community-release-el7-7.noarch.rpm' saved [8984/8984]
3 安装MysqL的Yum Repository
安装完MysqL的Yum Repository,每次执行yum update都会检查MysqL是否更新。
[root@typecodes ~]# yum -y install MysqL57-community-release-el7-7.noarch.rpm
Loaded plugins: axelget,fastestmirror,langpacks
Examining MysqL57-community-release-el7-7.noarch.rpm: MysqL57-community-release-el7-7.noarch
Marking MysqL57-community-release-el7-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package MysqL57-community-release.noarch 0:el7-7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package          Arch      Version     Repository             Size
=======================================================================================================================================================================
Installing:
 MysqL57-community-release      noarch      el7-7      /MysqL57-community-release-el7-7.noarch      7.8 k
transaction SumMary
=======================================================================================================================================================================
Install 1 Package
@R_590_10586@l size: 7.8 k
Installed size: 7.8 k
Downloading packages:
Running transaction check
Running transaction test
transaction test succeeded
Running transaction
 Installing : MysqL57-community-release-el7-7.noarch                            1/1 
 Verifying : MysqL57-community-release-el7-7.noarch                           1/1
Installed:
 MysqL57-community-release.noarch 0:el7-7
Complete!

3 安装MysqL数据库的服务器版本

[root@typecodes ~]# yum -y install MysqL-community-server
Loaded plugins: axelget,langpacks
No Metadata available for base
No Metadata available for epel
No Metadata available for extras
repomd.xml                                  | 2.5 kB 00:00:00  
update mysql-connectors-community Metadata successfully
repomd.xml                                  | 2.5 kB 00:00:00  
update MysqL-tools-community Metadata successfully
repomd.xml                                  | 2.5 kB 00:00:00  
update MysqL57-community Metadata successfully
No Metadata available for updates
mysql-connectors-community                              | 2.5 kB 00:00:00  
MysqL-tools-community                               | 2.5 kB 00:00:00  
MysqL57-community                                | 2.5 kB 00:00:00  
(1/3): MysqL-tools-community/x86_64/priMary_db                         | 24 kB 00:00:01  
(2/3): MysqL57-community/x86_64/priMary_db                          | 28 kB 00:00:01  
(3/3): mysql-connectors-community/x86_64/priMary_db                        | 8.6 kB 00:00:02  
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.neusoft.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package MysqL-community-server.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: MysqL-community-common(x86-64) = 5.7.10-1.el7 for package: MysqL-community-server-5.7.10-1.el7.x86_64
--> Processing Dependency: MysqL-community-client(x86-64) = 5.7.10-1.el7 for package: MysqL-community-server-5.7.10-1.el7.x86_64
--> Running transaction check
---> Package MysqL-community-client.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: MysqL-community-libs(x86-64) = 5.7.10-1.el7 for package: MysqL-community-client-5.7.10-1.el7.x86_64
---> Package MysqL-community-common.x86_64 0:5.7.10-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted
--> Processing Dependency: libMysqLclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libMysqLclient.so.18(libMysqLclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package MysqL-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleTing
--> Running transaction check
---> Package MysqL-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleTing
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package           Arch       Version        Repository        Size
=======================================================================================================================================================================
Installing:
 MysqL-community-libs        x86_64      5.7.10-1.el7       MysqL57-community      2.2 M
  replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 MysqL-community-libs-compat      x86_64      5.7.10-1.el7       MysqL57-community      2.0 M
  replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 MysqL-community-server        x86_64      5.7.10-1.el7       MysqL57-community      142 M
Installing for dependencies:
 MysqL-community-client        x86_64      5.7.10-1.el7       MysqL57-community       24 M
 MysqL-community-common        x86_64      5.7.10-1.el7       MysqL57-community      269 k
transaction SumMary
=======================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
@R_590_10586@l download size: 171 M
Downloading packages:
MysqL-community-server-5.7.10-1.el7.x86_64.rpm                         | 142 MB 00:03:42  
MysqL-community-libs-compat-5.7.10-1.el7.x86_64.rpm                        | 2.0 MB 00:00:03  
MysqL-community-libs-5.7.10-1.el7.x86_64.rpm                         | 2.2 MB 00:00:05  
MysqL-community-client-5.7.10-1.el7.x86_64.rpm                         | 24 MB 00:00:41  
warning: /var/cache/yum/x86_64/7/MysqL57-community/packages/MysqL-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY00 ETA 
Public key for MysqL-community-common-5.7.10-1.el7.x86_64.rpm is not installed
MysqL-community-common-5.7.10-1.el7.x86_64.rpm                         | 269 kB 00:00:01  
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL
ImporTing GPG key 0x5072E1F5:
 Userid  : "MysqL Release ENGIneering <MysqL-build@oss.Oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package : MysqL57-community-release-el7-7.noarch (@/MysqL57-community-release-el7-7.noarch)
 From  : /etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL
Running transaction check
Running transaction test
transaction test succeeded
Running transaction
 Installing : MysqL-community-common-5.7.10-1.el7.x86_64                           1/6 
 Installing : MysqL-community-libs-5.7.10-1.el7.x86_64                           2/6 
 Installing : MysqL-community-client-5.7.10-1.el7.x86_64                           3/6 
 Installing : MysqL-community-server-5.7.10-1.el7.x86_64                           4/6 
 Installing : MysqL-community-libs-compat-5.7.10-1.el7.x86_64                          5/6 
 Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6 
 Verifying : MysqL-community-server-5.7.10-1.el7.x86_64                           1/6 
 Verifying : MysqL-community-libs-compat-5.7.10-1.el7.x86_64                          2/6 
 Verifying : MysqL-community-common-5.7.10-1.el7.x86_64                           3/6 
 Verifying : MysqL-community-libs-5.7.10-1.el7.x86_64                           4/6 
 Verifying : MysqL-community-client-5.7.10-1.el7.x86_64                           5/6 
 Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6
Installed:
 MysqL-community-libs.x86_64 0:5.7.10-1.el7   MysqL-community-libs-compat.x86_64 0:5.7.10-1.el7   MysqL-community-server.x86_64 0:5.7.10-1.el7
Dependency Installed:
 MysqL-community-client.x86_64 0:5.7.10-1.el7          MysqL-community-common.x86_64 0:5.7.10-1.el7
replaced:
 mariadb-libs.x86_64 1:5.5.44-2.el7.centos
Complete!
[root@typecodes ~]# clear

最后的截图:

centos7.3 安装mysql5.7.18的详细教程

4 启动数据库:

[root@typecodes ~]# systemctl start MysqLd.service

然后使用命令systemctl status MysqLd.service查看MysqL数据库启动后的服务状态:

centos7.3 安装mysql5.7.18的详细教程

5 获取初始密码

使用YUM安装并启动MysqL服务后,MysqL进程会自动在进程日志中打印root用户的初始密码:

#######从MysqL进程日志中获取root用户的初始密码:ra%yk7urCBIh
[root@typecodes ~]# grep "password" /var/log/MysqLd.log
2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh
2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:47:44.755199Z 0 [Note] ShutTing down plugin 'validate_password'
2016-02-03T10:47:46.505844Z 0 [Note] ShutTing down plugin 'sha256_password'
2016-02-03T10:47:46.505851Z 0 [Note] ShutTing down plugin 'MysqL_native_password'

6 修改root用户密码

使用小节5中获取的root用户的初始密码,然后进行修改:

set global validate_password_policy =0;//默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。

set global validate_password_length=4;//指定了密码中数据的长度
alter user root@localhost identified by 'crow';//修改密码

增加远程访问权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'crow' WITH GRANT OPTION;
FLUSH PRIVILEGES;

退出MysqL,然后重启服务

systemctl restart MysqLd

防火墙打开3306端口

firewall-cmd --zone=public --add-port=3306/tcp --peRMANent

重启防火墙

firewall-cmd --reload
[root@typecodes ~]# MysqL -uroot -p
Enter password:    #######输入默认的root密码后回车
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 2
Server version: 5.7.10
Copyright (C) 2000,2015,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 'new password';
Query OK,0 rows affected (0.00 seC)
MysqL> exit
Bye

7 安装完毕

至此,使用在CentOS7中使用YUM方法安装MysqL5.7.10数据库完毕。如下所示,可以使用新的root密码登陆MysqL了。

[root@typecodes ~]# MysqL -uroot -ppassword
MysqL: [Warning] Using a password on the command linE interface can be insecure.
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 3
Server version: 5.7.10 MysqL Community Server (GPL)
Copyright (C) 2000,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> 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> show databases;
+--------------------+
| Database   |
+--------------------+
| information_scheR_336_11845@a |
| MysqL    |
| perfoRMANce_scheR_336_11845@a |
| sys    |
+--------------------+
4 rows in set (0.00 seC)
MysqL> clear
MysqL> exit
Bye
[root@typecodes ~]# clear

附录1:查看MysqL数据库的配置信息

@H_779_0@mysqL的配置文件依然是/etc/my.cnf,其它安装信息可以通过MysqL_config命令查看。其中,动态库文件存放在/usr/lib64/MysqL目录下。

centos7.3 安装mysql5.7.18的详细教程

附录2:对于C/C++等开发者

由于需要用到类似Mysql.h等头文件,需要执行下面的命令安装MysqL开发版本即可。

[root@typecodes ~]# yum -y install MysqL-community-devel

附录3:删除MysqL的Repository

因为小节3中安装了MysqL的Yum Repository,所以以后每次执行yum操作时,都会去检查更新。如果想要去掉这种自动检查操作的话,可以使用如下命令卸载MysqL的Repository即可。

[root@typecodes ~]# yum -y remove MysqL57-community-release-el7-7.noarch
update 2017.04.10 11:10

使用上面的yum方法也可以安装目前MysqL官网上最新的版本MysqL5.7.18。只要替换小节2中rmp包的版本即可,后续操作步骤不变。

wget -i -c http://dev.Mysql.com/get/MysqL57-community-release-el7-10.noarch.rpm

以上所述是小编给大家介绍的centos7.3 安装MysqL5.7.18的详细教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程小技巧网站的支持!

您可能感兴趣的文章:

  • Centos7.3下mysql5.7.18安装并修改初始密码的方法
  • CentOs7.x安装Mysql的详细教程
  • CentOS7使用rpm包安装mysql 5.7.18
  • CentOS7.2虚拟机上安装MySQL 5.6.32的教程
  • 在CentOS7系统上编译安装MySQL 5.7.13步骤详解
  • Centos7下编译安装配置Nginx+php+MySql环境
  • Centos7使用yum安装Mysql5.7.19的详细步骤
  • CentOS7使用dnf安装mysql的方法

大佬总结

以上是大佬教程为你收集整理的centos7.3 安装mysql5.7.18的详细教程全部内容,希望文章能够帮你解决centos7.3 安装mysql5.7.18的详细教程所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: