您的位置:首页 > 运维架构 > Linux

Centos7安装mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

2017-07-26 19:41 483 查看
初学Linux,为了安装JIRA选择安装MySQL数据库,折腾了一天,也百度了很多别人的文章,终于在参考

http://blog.csdn.net/tanjun592/article/details/71797972?locationNum=9&fps=1

下跨过了这个“小坑”。

一、官网下载MySQL安装包

https://dev.MySQL.com/downloads/file/?id=469456

二、解压安装包

#tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

解压后会生成很多文件。

【借用别人的内容】[root@hostaa mysql_rpm]# ls -l

总用量 1141908

-rw-r–r– 1 root root 584652800 5月 13 01:02 mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

-rw-r–r– 1 7155 31415 25079412 3月 20 17:40 mysql-community-client-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 277784 3月 20 17:40 mysql-community-common-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 3777808 3月 20 17:40 mysql-community-devel-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 45493312 3月 20 17:40 mysql-community-embedded-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 23924496 3月 20 17:40 mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 126060264 3月 20 17:40 mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 2237888 3月 20 17:40 mysql-community-libs-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 2113196 3月 20 17:40 mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 54661812 3月 20 17:40 mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 169622200 3月 20 17:41 mysql-community-server-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 14501488 3月 20 17:41 mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm

-rw-r–r– 1 7155 31415 116887988 3月 20 17:41 mysql-community-test-5.7.18-1.el7.x86_64.rpm

三、按顺序rpm

common–>libs–>client–>server的顺序。若不按照此顺序,也会有一定“依赖”关系的提醒。

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

【怪自己没有仔细看提示内容(其实是英语差,被卡中的地方)conflicts with file】可能会有一个提示信息:

警告:mysql-community-common-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

准备中… ################################# [100%]

file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64conflicts with filefrom package mariadb-libs-1:5.5.44-2.el7.centos.x86_64

file /usr/share/mysql/danish/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.44-2.el7.centos.x86_64

… …

file /usr/share/mysql/estonian/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.44-2.el7.centos.x86_64

file /usr/share/mysql/french/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.44-2.el7.centos.x86_64

… …

来自mysql-ccommunity-common-5.7.18-1.el7.x86_的文件和mariadb-libs-1:5.5.44-2.el7.centos.x86_64的文件冲突?什么意思?查了下:出现以上安装错误列表的原因是:系统已经安装了其他版本的mysql-libs包和mysql数据库文件导致不兼容

解决:# yum remove mysql-libs

已加载插件:fastestmirror, langpacks

正在解决依赖关系

–> 正在检查事务

—> 软件包 mariadb-libs.x86_64.1.5.5.44-2.el7.centos 将被 删除

–> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-6.el7.x86_64 需要

–> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-6.el7.x86_64 需要

–> 正在检查事务

—> 软件包 postfix.x86_64.2.2.10.1-6.el7 将被 删除

–> 解决依赖关系完成

base/7/x86_64 | 3.6 kB 00:00:00

extras/7/x86_64 | 3.4 kB 00:00:00

updates/7/x86_64 | 3.4 kB 00:00:00

依赖关系解决

Package 架构 版本 源 大小

正在删除:

mariadb-libs x86_64 1:5.5.44-2.el7.centos @anaconda 4.4 M

为依赖而移除:

postfix x86_64 2:2.10.1-6.el7 @anaconda 12 M

事务概要

移除 1 软件包 (+1 依赖软件包)

安装大小:17 M

是否继续?[y/N]:y

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

警告:RPM 数据库已被非 yum 程序修改。

** 发现 4 个已存在的 RPM 数据库问题, ‘yum check’ 输出如下:

icedtea-web-1.6.1-4.el7.x86_64 有缺少的需求 java-1.8.0-openjdk

jline-1.0-8.el7.noarch 有缺少的需求 java >= (‘0’, ‘1.5’, None)

1:libreoffice-core-4.3.7.2-5.el7.x86_64 有缺少的需求 java-headless >= (‘1’, ‘1.6’, None)

1:libreoffice-ure-4.3.7.2-5.el7.x86_64 有缺少的需求 libjvm.so()(64bit)

正在删除 : 2:postfix-2.10.1-6.el7.x86_64 1/2

正在删除 : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 2/2

验证中 : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 1/2

验证中 : 2:postfix-2.10.1-6.el7.x86_64 2/2

删除:

mariadb-libs.x86_64 1:5.5.44-2.el7.centos

作为依赖被删除:

postfix.x86_64 2:2.10.1-6.el7

完毕!

类似的错误,都可以先试试彻底从centos中卸载mysql

然后再重新安装依次安装吧:

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

警告:mysql-community-common-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

准备中… ################################# [100%]

正在升级/安装…

1:mysql-community-common-5.7.18-1.e################################# [100%]

2)# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm

警告:mysql-community-libs-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

准备中… ################################# [100%]

正在升级/安装…

1:mysql-community-libs-5.7.18-1.el7################################# [100%]

3)# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm

警告:mysql-community-client-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

准备中… ################################# [100%]

正在升级/安装…

1:mysql-community-client-5.7.18-1.e################################# [100%]

4)# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm

警告:mysql-community-server-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

准备中… ################################# [100%]

正在升级/安装…

1:mysql-community-server-5.7.18-1.e################################# [100%]

5)# rpm -ivh mysql-community-devel-5.7.18-1.el7.x86_64.rpm (可选安装)

警告:mysql-community-devel-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

准备中… ################################# [100%]

正在升级/安装…

1:mysql-community-devel-5.7.18-1.el################################# [100%]

四、启动数据库

# systemctl start mysqld

查看状态:

# systemctl status mysqld

五、登录

1)使用my.cnf文件中自动生成一个密码

# cat /var/log/mysqld.log | grep password

2017-05-13T05:39:44.497086Z 1 [Note] A temporary password is generated for root@localhost: pKsO:Jin<4f%

密码:pKsO:Jin<4f%

2)使用root登录

#mysql -u root -p

Enter password:pKsO:Jin<4f%

3)修改密码

mysql>set password for
8e9b
root@localhost = password(‘asd123’);


4)修改安全级别

mysql> set global validate_password_policy=0;//0最低,1中级,2最强验证级别

5)创建普通用户:

create user ‘jirauser’ identified by ‘jiara123a’

用户jirauser,密码jira123a

五、授权远程连接

mysql>GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘Mysql5718%’ WITH GRANT OPTION;

Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.01 sec)

这样,我们就可以在其他电脑上的mysql客户端远程连接linux上的mysql数据库了:(例如在win cmd里面)

C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin>mysql -u root -pMysql5718% -h 192.168.231.8 -D roger

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

Your MySQL connection id is 18

Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>

(如果连不上,看看是不是防火墙开着的。)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos7 mysql 安装