centos 7 安装 mysql 5.7

发布时间:2017-7-9 7:11:03编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"centos 7 安装 mysql 5.7 ",主要涉及到centos 7 安装 mysql 5.7 方面的内容,对于centos 7 安装 mysql 5.7 感兴趣的同学可以参考一下。

1、环境

    Centos 7

 2、下载

官方网站https://dev.mysql.com/downloads/mysql/5.7.html#downloads ,选择要下载的版本,centos 7 同red hat ,所以选择操作系统为red had。

下载文件如:mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

3、解压安装

使用命令"tar -xf  mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar",解压程序包

得到文件:

mysql-community-client-5.7.18-1.el7.x86_64.rpm
mysql-community-common-5.7.18-1.el7.x86_64.rpm
mysql-community-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm
mysql-community-server-5.7.18-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm
mysql-community-test-5.7.18-1.el7.x86_64.rpm

安装

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

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

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

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

在安装过程中警告失败,如:

file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64...

需要卸载mariadb

方式1: 使用命令“rpm -qa|grep mariadb” 查找安装项,再使用命令“rpm -e --nodes  *** ”,如:

[root@localhost mysql]# rpm -qa|grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@localhost mysql]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64

方式2:使用命令“yum list installed |grep mariadb"查找安装项,再使用命令“yum remove *** ”,如:

[root@localhost mysql]# yum list installed |grep mariadb
mariadb-libs.x86_64                1:5.5.52-1.el7                      @base
[root@localhost mysql]# yum remove mariadb-libs.x86_64

卸载后正常,如

[root@localhost mysql]# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.18-1.e################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.18-1.el7################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.18-1.e################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.18-1.e################################# [100%]
[root@localhost mysql]#:

4、数据库初始化及设置用户密码

使用命令“mysqld --initialize --user=mysql ”,指定数据用户为“mysql”

使用命令“cat /var/log/mysqld.log” 查看数据库日志,查看原始密码,如:

[root@localhost mysql]# cat /var/log/mysqld.log
2017-07-02T15:30:25.274266Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-02T15:30:25.453876Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-07-02T15:30:25.556284Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-07-02T15:30:25.729883Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5edc5c08-5f3b-11e7-baff-000c29931b60.
2017-07-02T15:30:25.780510Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-07-02T15:30:25.782981Z 1 [Note] A temporary password is generated for root@localhost: 26Fp?yMzd3W%

找到在内容中可以看到一个临时密码被创建,数据库用户名:root, 密码:26Fp?yMzd3W%

使用命令“systemctl start mysqld.service”,启动数据库,可通过“systemctl status mysqld.service” 查看服务状态,其他还有“stop/restart/enable/disable”等服务命令

使用命令“mysql -u root -p”,复制log密码登陆数据库,如:

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

Enter password:

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

Your MySQL connection id is 6

Server version: 5.7.18

Copyright (c) 2000, 2017, 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  'yours password';    ”

5、防火墙开放端口3306。

[root@master ~]#  firewall-cmd --add-port=3306/tcp --permanent

[root@master ~]# firewall-cmd --reload


上一篇:java 读写文件常用方法
下一篇:Linux下进程描述(1)—进程控制块【转】 - 张昺华

相关文章

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。