centos6.9安装mysql记录

环境:centos6.9(虚拟机)安装mysql-community-server 5.7版本

说明:一定要把centos和mysql的版本对应好才能正确安装,不然会有很多解决不了的依赖问题
如果你是centos7.X 安装 el7
此处我是centos6.9 安装 el6
还有lscpu看下自己应该安装i686还是x86_64
此处我安装的是i686的

检查是否已经安装了mysql,如果有按照需求删除或者备份

[root@local ~]# rpm -qa | grep mysql

切记这四个rpm都是el6和i686
如果mysql-community-server安装的是el6.i686而mysql-community-client或者其他安装的是el7或者x86_64就会出现解决不了的依赖情况

下载如下软件包,或者你可以直接下载mysql-5.7.21-1.el6.i686.rpm-bundle.tar包含下面四个rpm包

  • mysql-community-server-5.7.21-1.el6.i686.rpm
  • mysql-community-client-5.7.21-1.el6.i686.rpm
  • mysql-community-common-5.7.21-1.el6.i686.rpm
  • mysql-community-libs-5.7.21-1.el6.i686.rpm

这里我是直接用wget下载的

[root@local ~]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-1.el6.i686.rpm-bundle.tar

先解压,然后查看有哪些包

[root@local ~]# tar -xvf mysql-5.7.21-1.el6.i686.rpm-bundle.tar 
[root@local ~]# ll
总用量 881028
-rw-r--r--. 1 root root     358268 12月 14 12:33 aircrackgui-1.4.9.tar.gz
-rw-r--r--. 1 root root       2006 12月  1 2016 CentOS6-Base-163.repo
-rw-r--r--. 1 root root  450897920 12月 15 00:00 mysql-5.7.21-1.el6.i686.rpm-bundle.tar
-rw-r--r--. 1 7155 31415  23031008 12月 28 2017 mysql-community-client-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415    337064 12月 28 2017 mysql-community-common-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415   3515344 12月 28 2017 mysql-community-devel-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415  37941856 12月 28 2017 mysql-community-embedded-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415 122678432 12月 28 2017 mysql-community-embedded-devel-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415   2105352 12月 28 2017 mysql-community-libs-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415   1694612 12月 28 2017 mysql-community-libs-compat-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415 157221192 12月 28 2017 mysql-community-server-5.7.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 31415 102362740 12月 28 2017 mysql-community-test-5.7.21-1.el6.i686.rpm

安装顺序:

  • mysql-community-common-5.7.21-1.el6.i686.rpm
  • mysql-community-libs-5.7.21-1.el6.i686.rpm
  • mysql-community-client-5.7.21-1.el6.i686.rpm
  • mysql-community-server-5.7.21-1.el6.i686.rpm
    具体安装过程:(可能当初安装的是centos minimal还是有太多依赖要解决,好在缺什么你就yum +依赖名字去安装就行了)
[root@local ~]# rpm -ivh mysql-community-common-5.7.21-1.el6.i686.rpm 
Preparing...                ########################################### [100%]
   1:mysql-community-common ########################################### [100%]
[root@local ~]# rpm -ivh mysql-community-libs-5.7.21-1.el6.i686.rpm 
error: Failed dependencies:
    libgcc_s.so.1 is needed by mysql-community-libs-5.7.21-1.el6.i686
    libgcc_s.so.1(GCC_3.0) is needed by mysql-community-libs-5.7.21-1.el6.i686
    libgcc_s.so.1(GLIBC_2.0) is needed by mysql-community-libs-5.7.21-1.el6.i686
    libstdc++.so.6 is needed by mysql-community-libs-5.7.21-1.el6.i686
    libstdc++.so.6(CXXABI_1.3) is needed by mysql-community-libs-5.7.21-1.el6.i686
    libstdc++.so.6(GLIBCXX_3.4) is needed by mysql-community-libs-5.7.21-1.el6.i686
[root@local ~]# yum install libgcc_s.so.1
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
解决依赖关系
--> 执行事务检查
---> Package libgcc.i686 0:4.4.7-18.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

==================================================================================================================================
 软件包                        架构                        版本                                 仓库                         大小
==================================================================================================================================
正在安装:
 libgcc                        i686                        4.4.7-18.el6                         base                        115 k

事务概要
==================================================================================================================================
Install       1 Package(s)

总下载量:115 k
Installed size: 144 k
确定吗?[y/N]:y
下载软件包:
libgcc-4.4.7-18.el6.i686.rpm                                                                               | 115 kB     00:00     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
Warning: RPMDB altered outside of yum.
  正在安装   : libgcc-4.4.7-18.el6.i686                                                                                       1/1 
  Verifying  : libgcc-4.4.7-18.el6.i686                                                                                       1/1 

已安装:
  libgcc.i686 0:4.4.7-18.el6                                                                                                      

完毕!
[root@local ~]# yum install libstdc++.so.6
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
解决依赖关系
--> 执行事务检查
---> Package libstdc++.i686 0:4.4.7-18.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

==================================================================================================================================
 软件包                          架构                       版本                                 仓库                        大小
==================================================================================================================================
正在安装:
 libstdc++                       i686                       4.4.7-18.el6                         base                       303 k

事务概要
==================================================================================================================================
Install       1 Package(s)

总下载量:303 k
Installed size: 908 k
确定吗?[y/N]:y
下载软件包:
libstdc++-4.4.7-18.el6.i686.rpm                                                                            | 303 kB     00:00     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
  正在安装   : libstdc++-4.4.7-18.el6.i686                                                                                    1/1 
  Verifying  : libstdc++-4.4.7-18.el6.i686                                                                                    1/1 

已安装:
  libstdc++.i686 0:4.4.7-18.el6                                                                                                   

完毕!
[root@local ~]# 
[root@local ~]# rpm -ivh mysql-community-libs-5.7.21-1.el6.i686.rpm 
Preparing...                ########################################### [100%]
   1:mysql-community-libs   ########################################### [100%]
[root@local ~]# rpm -ivh mysql-community-libs-5.7.21-1.el6.i686.rpm 
Preparing...                ########################################### [100%]
   1:mysql-community-libs   ########################################### [100%]
[root@local ~]# 
[root@local ~]# 
[root@local ~]# 
[root@local ~]# 
[root@local ~]# rpm -ivh mysql-community-client-5.7.21-1.el6.i686.rpm 
error: Failed dependencies:
    libncurses.so.5 is needed by mysql-community-client-5.7.21-1.el6.i686
    libtinfo.so.5 is needed by mysql-community-client-5.7.21-1.el6.i686
[root@local ~]# yum install libncurses.so.5
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
解决依赖关系
--> 执行事务检查
---> Package ncurses-libs.i686 0:5.7-4.20090207.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

==================================================================================================================================
 软件包                           架构                     版本                                    仓库                      大小
==================================================================================================================================
正在安装:
 ncurses-libs                     i686                     5.7-4.20090207.el6                      base                     249 k

事务概要
==================================================================================================================================
Install       1 Package(s)

总下载量:249 k
Installed size: 687 k
确定吗?[y/N]:y
下载软件包:
ncurses-libs-5.7-4.20090207.el6.i686.rpm                                                                   | 249 kB     00:00     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
Warning: RPMDB altered outside of yum.
  正在安装   : ncurses-libs-5.7-4.20090207.el6.i686                                                                           1/1 
  Verifying  : ncurses-libs-5.7-4.20090207.el6.i686                                                                           1/1 

已安装:
  ncurses-libs.i686 0:5.7-4.20090207.el6                                                                                          

完毕!
[root@local ~]# 
[root@local ~]# rpm -ivh mysql-community-client-5.7.21-1.el6.i686.rpm 
Preparing...                ########################################### [100%]
   1:mysql-community-client ########################################### [100%]
[root@local ~]# rpm -ivh mysql-community-server-5.7.21-1.el6.i686.rpm 
error: Failed dependencies:
    libaio.so.1 is needed by mysql-community-server-5.7.21-1.el6.i686
    libaio.so.1(LIBAIO_0.1) is needed by mysql-community-server-5.7.21-1.el6.i686
    libaio.so.1(LIBAIO_0.4) is needed by mysql-community-server-5.7.21-1.el6.i686
    libsasl2.so.2 is needed by mysql-community-server-5.7.21-1.el6.i686
    mysql-community-client(x86-32) >= 5.7.9 is needed by mysql-community-server-5.7.21-1.el6.i686
[root@local ~]# rom -ivh mysql-community-client-5.7.21-1.el6.i686.rpm 
-bash: rom: command not found
[root@local ~]# rpm -ivh mysql-community-client-5.7.21-1.el6.i686.rpm 
Preparing...                ########################################### [100%]
   1:mysql-community-client ########################################### [100%]
[root@local ~]# 
[root@local ~]# 
[root@local ~]# rpm -ivh mysql-community-server-5.7.21-1.el6.i686.rpm 
error: Failed dependencies:
    libaio.so.1 is needed by mysql-community-server-5.7.21-1.el6.i686
    libaio.so.1(LIBAIO_0.1) is needed by mysql-community-server-5.7.21-1.el6.i686
    libaio.so.1(LIBAIO_0.4) is needed by mysql-community-server-5.7.21-1.el6.i686
    libsasl2.so.2 is needed by mysql-community-server-5.7.21-1.el6.i686
[root@local ~]# yum install libaio.so.1
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
解决依赖关系
--> 执行事务检查
---> Package libaio.i686 0:0.3.107-10.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

==================================================================================================================================
 软件包                       架构                       版本                                    仓库                        大小
==================================================================================================================================
正在安装:
 libaio                       i686                       0.3.107-10.el6                          base                        21 k

事务概要
==================================================================================================================================
Install       1 Package(s)

总下载量:21 k
Installed size: 31 k
确定吗?[y/N]:y
下载软件包:
libaio-0.3.107-10.el6.i686.rpm                                                                             |  21 kB     00:00     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
Warning: RPMDB altered outside of yum.
  正在安装   : libaio-0.3.107-10.el6.i686                                                                                     1/1 
  Verifying  : libaio-0.3.107-10.el6.i686                                                                                     1/1 

已安装:
  libaio.i686 0:0.3.107-10.el6                                                                                                    

完毕!
[root@local ~]# yum install libsasl2.so.2
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
解决依赖关系
--> 执行事务检查
---> Package cyrus-sasl-lib.i686 0:2.1.23-15.el6_6.2 will be 安装
--> 处理依赖关系 libdb-4.7.so,它被软件包 cyrus-sasl-lib-2.1.23-15.el6_6.2.i686 需要
--> 执行事务检查
---> Package db4.i686 0:4.7.25-22.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

==================================================================================================================================
 软件包                             架构                     版本                                  仓库                      大小
==================================================================================================================================
正在安装:
 cyrus-sasl-lib                     i686                     2.1.23-15.el6_6.2                     base                     136 k
为依赖而安装:
 db4                                i686                     4.7.25-22.el6                         base                     581 k

事务概要
==================================================================================================================================
Install       2 Package(s)

总下载量:717 k
Installed size: 1.8 M
确定吗?[y/N]:y
下载软件包:
(1/2): cyrus-sasl-lib-2.1.23-15.el6_6.2.i686.rpm                                                           | 136 kB     00:00     
(2/2): db4-4.7.25-22.el6.i686.rpm                                                                          | 581 kB     00:00     
----------------------------------------------------------------------------------------------------------------------------------
总计                                                                                              1.5 MB/s | 717 kB     00:00     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
  正在安装   : db4-4.7.25-22.el6.i686                                                                                         1/2 
  正在安装   : cyrus-sasl-lib-2.1.23-15.el6_6.2.i686                                                                          2/2 
  Verifying  : cyrus-sasl-lib-2.1.23-15.el6_6.2.i686                                                                          1/2 
  Verifying  : db4-4.7.25-22.el6.i686                                                                                         2/2 

已安装:
  cyrus-sasl-lib.i686 0:2.1.23-15.el6_6.2                                                                                         

作为依赖被安装:
  db4.i686 0:4.7.25-22.el6                                                                                                        

完毕!
[root@local ~]# rpm -ivh mysql-community-server-5.7.21-1.el6.i686.rpm 
Preparing...                ########################################### [100%]
   1:mysql-community-server ########################################### [100%]
[root@local ~]# 

启动数据库

[root@local ~]# service mysqld start
初始化 MySQL 数据库:                                      [确定]
正在启动 mysqld:                                          [确定]
[root@local ~]# 

从mysql安装日志中找出初始密码

[root@local ~]# grep "password" /var/log/mysqld.log 
2017-12-14T16:28:26.885966Z 1 [Note] A temporary password is generated for root@localhost: MDMYVwaDa6!l
2017-12-14T16:28:31.589914Z 2 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO)
[root@local ~]# 

登录mysql并修改密码

[root@local ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.21

Copyright (c) 2000, 2018, 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> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('*******');

PS:修改mysql的密码有很多种,有时间再开一篇文章详细介绍

你可能感兴趣的:(centos6.9安装mysql记录)