centOS6.5 安装mysql5.7最新版流程

1检查是否已经安装mysql ,指令:

rpm -qa | grep MySQL

rpm -qa | grep mysql
[root@mysql2 ~]# rpm -qa | grep MySQL
MySQL-python-1.2.3-0.3.c1.1.el6.x86_64
[root@mysql2 ~]# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64


 删除指令:rpm -e  name

[root@mysql2 ~]# rpm -e MySQL-python-1.2.3-0.3.c1.1.el6.x86_64


其他的也删除,上面只是举个例子。

查看系统mysql的版本

[root@mysql2 ~]# yum list mysql*
Loaded plugins: fastestmirror, security
Determining fastest mirrors
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
base                                                                                                                                                                    | 3.7 kB     00:00     
base/primary_db                                                                                                                                                         | 4.7 MB     00:02     
extras                                                                                                                                                                  | 3.4 kB     00:00     
extras/primary_db                                                                                                                                                       |  27 kB     00:00     
updates                                                                                                                                                                 | 3.4 kB     00:00     
updates/primary_db                                                                                                                                                      | 2.4 MB     00:01     
Installed Packages
mysql.x86_64                                                                    5.1.71-1.el6                                                           @anaconda-CentOS-201311272149.x86_64/6.5
mysql-connector-odbc.x86_64                                                     5.1.5r1144-7.el6                                                       @anaconda-CentOS-201311272149.x86_64/6.5
mysql-libs.x86_64                                                               5.1.71-1.el6                                                           @anaconda-CentOS-201311272149.x86_64/6.5
Available Packages
MySQL-python.x86_64                                                             1.2.3-0.3.c1.1.el6                                                     base                                    
mysql.x86_64                                                                    5.1.73-8.el6_8                                                         base                                    
mysql-bench.x86_64                                                              5.1.73-8.el6_8                                                         base                                    
mysql-connector-java.noarch                                                     1:5.1.17-6.el6                                                         base                                    
mysql-devel.i686                                                                5.1.73-8.el6_8                                                         base                                    
mysql-devel.x86_64                                                              5.1.73-8.el6_8                                                         base                                    
mysql-embedded.i686                                                             5.1.73-8.el6_8                                                         base                                    
mysql-embedded.x86_64                                                           5.1.73-8.el6_8                                                         base                                    
mysql-embedded-devel.i686                                                       5.1.73-8.el6_8                                                         base                                    
mysql-embedded-devel.x86_64                                                     5.1.73-8.el6_8                                                         base                                    
mysql-libs.i686                                                                 5.1.73-8.el6_8                                                         base                                    
mysql-libs.x86_64                                                               5.1.73-8.el6_8                                                         base                                    
mysql-server.x86_64                                                             5.1.73-8.el6_8                                                         base                                    
mysql-test.x86_64       

                                
查看以后发现版本过低 

2 yum安装mysql最新版本


下载指令: 
wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm 

[root@mysql2 ~]# wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm 
--2018-12-21 19:23:56--  http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm%C2%A0
Resolving dev.mysql.com... 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm%C2%A0 [following]
--2018-12-21 19:24:05--  https://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm%C2%A0
Connecting to dev.mysql.com|137.254.60.11|:443... connected.
ERROR: certificate common name “www.mysql.com” doesn’t match requested host name “dev.mysql.com”.
To connect to dev.mysql.com insecurely, use ‘--no-check-certificate’.


发现不行,更改指令:wget --no-check-certificate  http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm 

[root@mysql2 ~]# wget --no-check-certificate  http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
--2018-12-21 19:43:56--  http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
Resolving dev.mysql.com... 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm [following]
--2018-12-21 19:44:05--  https://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
Connecting to dev.mysql.com|137.254.60.11|:443... connected.
WARNING: certificate common name “www.mysql.com” doesn’t match requested host name “dev.mysql.com”.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql57-community-release-el6-7.noarch.rpm [following]
--2018-12-21 19:44:06--  https://repo.mysql.com//mysql57-community-release-el6-7.noarch.rpm
Resolving repo.mysql.com... 104.77.36.72
Connecting to repo.mysql.com|104.77.36.72|:443... connected.
WARNING: certificate common name “cdn.mysql.com” doesn’t match requested host name “repo.mysql.com”.
HTTP request sent, awaiting response... 200 OK
Length: 8848 (8.6K) [application/x-redhat-package-manager]
Saving to: “mysql57-community-release-el6-7.noarch.rpm”
 
100%[=====================================================================================================================================================>] 8,848       --.-K/s   in 0.005s  
 
2018-12-21 19:44:15 (1.59 MB/s) - “mysql57-community-release-el6-7.noarch.rpm” saved [8848/8848]
 
[root@mysql2 ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  mysql57-community-release-el6-7.noarch.rpm


可以,通过 ls 查看可以看到

安装下载的mysql仓库

[root@mysql2 ~]# rpm -ivh mysql57-community-release-el6-7.noarch.rpm 
warning: mysql57-community-release-el6-7.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql57-community-relea########################################### [100%]


查看源的启用情况

[root@mysql2 ~]# yum repolist enabled
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
mysql-connectors-community                                                                                                                                              | 2.5 kB     00:00     
mysql-connectors-community/primary_db                                                                                                                                   |  27 kB     00:00     
mysql-tools-community                                                                                                                                                   | 2.5 kB     00:00     
mysql-tools-community/primary_db                                                                                                                                        |  45 kB     00:00     
mysql57-community                                                                                                                                                       | 2.5 kB     00:00     
mysql57-community/primary_db                                                                                                                                            | 164 kB     00:00     
repo id                                                                                     repo name                                                                                    status
base                                                                                        CentOS-6 - Base                                                                              6,713
extras                                                                                      CentOS-6 - Extras                                                                               35
mysql-connectors-community                                                                  MySQL Connectors Community                                                                      66
mysql-tools-community                                                                       MySQL Tools Community                                                                           68
mysql57-community                                                                           MySQL 5.7 Community Server                                                                     291
updates                                                                                     CentOS-6 - Updates                                                                             255
repolist: 7,428


看见  MySQL 5.7 Community Server   就可以

查看下现在mysql的版本 yum list mysql-community*

[root@mysql2 ~]# yum list mysql-community*
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
Available Packages
mysql-community-client.i686                                                                        5.7.24-1.el6                                                               mysql57-community
mysql-community-client.x86_64                                                                      5.7.24-1.el6                                                               mysql57-community
mysql-community-common.i686                                                                        5.7.24-1.el6                                                               mysql57-community
mysql-community-common.x86_64                                                                      5.7.24-1.el6                                                               mysql57-community
mysql-community-devel.i686                                                                         5.7.24-1.el6                                                               mysql57-community
mysql-community-devel.x86_64                                                                       5.7.24-1.el6                                                               mysql57-community
mysql-community-embedded.i686                                                                      5.7.24-1.el6                                                               mysql57-community
mysql-community-embedded.x86_64                                                                    5.7.24-1.el6                                                               mysql57-community
mysql-community-embedded-devel.i686                                                                5.7.24-1.el6                                                               mysql57-community
mysql-community-embedded-devel.x86_64                                                              5.7.24-1.el6                                                               mysql57-community
mysql-community-libs.i686                                                                          5.7.24-1.el6                                                               mysql57-community
mysql-community-libs.x86_64                                                                        5.7.24-1.el6                                                               mysql57-community
mysql-community-libs-compat.i686                                                                   5.7.24-1.el6                                                               mysql57-community
mysql-community-libs-compat.x86_64                                                                 5.7.24-1.el6                                                               mysql57-community
mysql-community-release.noarch                                                                     el6-7                                                                      mysql57-community
mysql-community-server.x86_64                                                                      5.7.24-1.el6                                                               mysql57-community
mysql-community-test.x86_64                                                                        5.7.24-1.el6                                                               mysql57-community
[root@mysql2 ~]# 


5.7.24应该是最新版,5.7的优势很大

安装mysql5.7.24

yum -y install mysql-server

查看安装情况

[root@mysql2 ~]# rpm -qa | grep mysql
mysql-community-libs-compat-5.7.24-1.el6.x86_64
mysql57-community-release-el6-7.noarch
mysql-community-common-5.7.24-1.el6.x86_64
mysql-community-client-5.7.24-1.el6.x86_64
mysql-connector-odbc-8.0.13-1.el6.x86_64
mysql-community-libs-5.7.24-1.el6.x86_64
mysql-community-server-5.7.24-1.el6.x86_64


启动:

[root@mysql2 ~]# service mysqld start
Initializing MySQL database:                               [FAILED]
[root@mysql2 ~]# service mysqld start
Starting mysqld:                                           [  OK  ]

设置开机启动

chkconfig mysqld on


mysql安装成功后创建的超级用户'root'@'localhost'的密码会被存储在/var/log/mysqld.log,可以使用如下命令查看密码

grep 'temporary password' /var/log/mysqld.log

 

[root@mysql2 ~]# grep 'temporary password' /var/log/mysqld.log
2018-12-21T12:55:02.548184Z 1 [Note] A temporary password is generated for root@localhost: #5o4gtm%H#wS


#5o4gtm%H#wS 这个是我的初始密码

使用mysql生成的'root'@'localhost'用户和密码登录数据库,并修改 其密码,具体命令

[

root@mysql2 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.24
 
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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.00 sec)


创建用户,允许远程接入:

mysql> grant all on *.* to  test@"%" Identified by "test";
Query OK, 0 rows affected, 1 warning (0.01 sec)
 
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
 
mysql> 


开通3306端口,就可以远程接入了。

重启mysql服务:

service mysqld restart

#关闭服务
service mysqld stop

启动成功后执行netstat -tunlp|grep 3306就可以看到mysqld已经启动了3306端口的监听。

[root@localhost ~]# netstat -tunlp|grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2094/mysqld

附: 几个配置问题

MySQL的my.cnf文件(默认5.7.18下没有my-default.cnf)

 

 

 

大功告成! 
--------------------- 
作者:tanlongkui 
来源:CSDN 
原文:https://blog.csdn.net/tanlongkui/article/details/85158934 
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值