文档章节

Centos 下 mysql 安装过程

o
 osc_gu9d45li
发布于 2019/04/03 20:48
字数 1988
阅读 13
收藏 0

精选30+云产品,助力企业轻松上云!>>>


1. 检查系统自带的Mysql,并卸载自带的版本

 

 

[root@iZ2366ycl7sZ config]# yum list installed |grep mysql
mysql.x86_64            5.1.73-5.el6_6  @base                                   
mysql-libs.x86_64       5.1.73-5.el6_6  @base                                   
php56w-mysql.x86_64     5.6.40-1.w6     @webtatic

 

 

 

2. 卸载系统自带的mysql及其依赖 

 

[root@iZ2366ycl7sZ config]# yum -y remove mysql-libs.x86_64
Loaded plugins: security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.73-5.el6_6 will be erased
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: mysql-libs = 5.1.73-5.el6_6 for package: mysql-5.1.73-5.el6_6.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-5.el6_6 will be erased
---> Package php56w-mysql.x86_64 0:5.6.40-1.w6 will be erased
---> Package postfix.x86_64 2:2.6.6-6.el6_5 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                          Arch                       Version                                Repository                     Size
========================================================================================================================================
Removing:
 mysql-libs                       x86_64                     5.1.73-5.el6_6                         @base                         4.0 M
Removing for dependencies:
 mysql                            x86_64                     5.1.73-5.el6_6                         @base                         2.4 M
 php56w-mysql                     x86_64                     5.6.40-1.w6                            @webtatic                     457 k
 postfix                          x86_64                     2:2.6.6-6.el6_5                        @updates                      9.7 M

Transaction Summary
========================================================================================================================================
Remove        4 Package(s)

Installed size: 17 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : php56w-mysql-5.6.40-1.w6.x86_64                                                                                      1/4 
  Erasing    : 2:postfix-2.6.6-6.el6_5.x86_64                                                                                       2/4 
  Erasing    : mysql-5.1.73-5.el6_6.x86_64                                                                                          3/4 
  Erasing    : mysql-libs-5.1.73-5.el6_6.x86_64                                                                                     4/4 
  Verifying  : mysql-libs-5.1.73-5.el6_6.x86_64                                                                                     1/4 
  Verifying  : php56w-mysql-5.6.40-1.w6.x86_64                                                                                      2/4 
  Verifying  : mysql-5.1.73-5.el6_6.x86_64                                                                                          3/4 
  Verifying  : 2:postfix-2.6.6-6.el6_5.x86_64                                                                                       4/4 

Removed:
  mysql-libs.x86_64 0:5.1.73-5.el6_6                                                                                                    

Dependency Removed:
  mysql.x86_64 0:5.1.73-5.el6_6              php56w-mysql.x86_64 0:5.6.40-1.w6              postfix.x86_64 2:2.6.6-6.el6_5             

Complete!

 

3. 给CentOS添加rpm源,并且选择较新的源

 

1)下载rpm包

 

[root@iZ2366ycl7sZ software]# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm --no-check-certificate
--2019-03-29 14:45:46--  http://dev.mysql.com/get/mysql-community-release-el6-5.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/mysql-community-release-el6-5.noarch.rpm [following]
--2019-03-29 14:45:46--  https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Connecting to dev.mysql.com|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm [following]
--2019-03-29 14:45:48--  https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm
Resolving repo.mysql.com... 104.127.195.16
Connecting to repo.mysql.com|104.127.195.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5824 (5.7K) [application/x-redhat-package-manager]
Saving to: “mysql-community-release-el6-5.noarch.rpm”

100%[==============================================================================================>] 5,824       --.-K/s   in 0s      

2019-03-29 14:45:48 (506 MB/s) - “mysql-community-release-el6-5.noarch.rpm” saved [5824/5824]

 

2)安装本地mysql源

 

[root@iZ2366ycl7sZ software]# yum localinstall mysql-community-release-el6-5.noarch.rpm
Loaded plugins: security
Setting up Local Package Process
Examining mysql-community-release-el6-5.noarch.rpm: mysql-community-release-el6-5.noarch
Marking mysql-community-release-el6-5.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el6-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                              Arch                Version              Repository                                          Size
========================================================================================================================================
Installing:
 mysql-community-release              noarch              el6-5                /mysql-community-release-el6-5.noarch              4.3 k

Transaction Summary
========================================================================================================================================
Install       1 Package(s)

Total size: 4.3 k
Installed size: 4.3 k
Is this ok [y/N]: y
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-release-el6-5.noarch                                                                                 1/1 
  Verifying  : mysql-community-release-el6-5.noarch                                                                                 1/1 

Installed:
  mysql-community-release.noarch 0:el6-5                                                                                                

Complete!

 

3)验证是否安装成功

 

[root@iZ2366ycl7sZ software]# yum repolist all | grep mysql
mysql-connectors-community        MySQL Connectors Community     enabled:     83
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community             MySQL Tools Community          enabled:     74
mysql-tools-community-source      MySQL Tools Community - Source disabled
mysql55-community                 MySQL 5.5 Community Server     disabled
mysql55-community-source          MySQL 5.5 Community Server - S disabled
mysql56-community                 MySQL 5.6 Community Server     enabled:    493
mysql56-community-source          MySQL 5.6 Community Server - S disabled
mysql57-community-dmr             MySQL 5.7 Community Server Dev disabled
mysql57-community-dmr-source      MySQL 5.7 Community Server Dev disabled

 

4)修改默认版本为5.7

 

 

注:如下是截取的老徐之前文章 -》原文 http://istester.com/huanjing/134.html

 


如上,默认是5.6版本可用,如果想安装5.7怎么操作?

有如下两个方法:

 

方法一:

执行:

yum-config-manager --disable mysql56-community

yum-config-manager --enable mysql57-community-dmr

 

如上操作,是把5.6禁用,把5.7启用

此法,会有异常情况:

如果执行命令出现如下错误:

-bash: yum-config-manager: command not found

可用执行如下命令解决,然后继续上面的操作命令:

yum -y install yum-utils

 

注意:如上操作可能有一部分同学的会出现一些问题;好处是操作简单,两个命令搞定~

如果有问题,底部给老徐留言~

 

 

方法二:

直接编辑配置文件,简单、直接,基本不会出现错误~

vi /etc/yum.repos.d/mysql-community.repo 

把5.6的enabled=0

把5.7的enabled=1

然后保存就ok

 

# Enable to use MySQL 5.5

[mysql55-community]

name=MySQL 5.5 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 

# Enable to use MySQL 5.6

[mysql56-community]

name=MySQL 5.6 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 

# Note: MySQL 5.7 is currently in development. For use at your own risk.

# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/

[mysql57-community-dmr]

name=MySQL 5.7 Community Server Development Milestone Release

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


如上,颜色标记处 。

此时,再执行:

yum repolist all | grep mysql

就可以看到,5.7是启用的

 

 

[root@localhost webserver]# yum repolist all | grep mysql

mysql-connectors-community        MySQL Connectors Community         启用:    21

mysql-connectors-community-source MySQL Connectors Community - Sourc 禁用

mysql-tools-community             MySQL Tools Community              启用:    38

mysql-tools-community-source      MySQL Tools Community - Source     禁用

mysql55-community                 MySQL 5.5 Community Server         禁用

mysql55-community-source          MySQL 5.5 Community Server - Sourc 禁用

mysql56-community                 MySQL 5.6 Community Server         禁用

mysql56-community-source          MySQL 5.6 Community Server - Sourc 禁用

mysql57-community-dmr             MySQL 5.7 Community Server Develop 启用:   130

mysql57-community-dmr-source      MySQL 5.7 Community Server Develop 禁用


如上 。

OK,至此,基础准备工作完成 。

 

 

 

4. 安装mysql

执行如下命令:

yum install mysql-community-server

 

[root@iZ2366ycl7sZ software]# yum install mysql-community-server
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.25-1.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.25-1.el6 for package: mysql-community-server-5.7.25-1.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.25-1.el6.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.25-1.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.25-1.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.7.25-1.el6 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.25-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                                Arch                   Version                      Repository                             Size
========================================================================================================================================
Installing:
 mysql-community-server                 x86_64                 5.7.25-1.el6                 mysql57-community-dmr                 153 M
Installing for dependencies:
 mysql-community-client                 x86_64                 5.7.25-1.el6                 mysql57-community-dmr                  23 M
 mysql-community-common                 x86_64                 5.7.25-1.el6                 mysql57-community-dmr                 332 k
 mysql-community-libs                   x86_64                 5.7.25-1.el6                 mysql57-community-dmr                 2.1 M

Transaction Summary
========================================================================================================================================
Install       4 Package(s)

Total download size: 178 M
Installed size: 887 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): mysql-community-client-5.7.25-1.el6.x86_64.rpm                                                            |  23 MB     00:01     
(2/4): mysql-community-common-5.7.25-1.el6.x86_64.rpm                                                            | 332 kB     00:00     
(3/4): mysql-community-libs-5.7.25-1.el6.x86_64.rpm                                                              | 2.1 MB     00:00     
(4/4): mysql-community-server-5.7.25-1.el6.x86_64.rpm                                                            | 153 MB     00:04     
----------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                    32 MB/s | 178 MB     00:05     
warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
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>
 Package: mysql-community-release-el6-5.noarch (@/mysql-community-release-el6-5.noarch)
 From   : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-common-5.7.25-1.el6.x86_64                                                                           1/4 
  Installing : mysql-community-libs-5.7.25-1.el6.x86_64                                                                             2/4 
  Installing : mysql-community-client-5.7.25-1.el6.x86_64                                                                           3/4 
  Installing : mysql-community-server-5.7.25-1.el6.x86_64                                                                           4/4 
  Verifying  : mysql-community-libs-5.7.25-1.el6.x86_64                                                                             1/4 
  Verifying  : mysql-community-common-5.7.25-1.el6.x86_64                                                                           2/4 
  Verifying  : mysql-community-client-5.7.25-1.el6.x86_64                                                                           3/4 
  Verifying  : mysql-community-server-5.7.25-1.el6.x86_64                                                                           4/4 

Installed:
  mysql-community-server.x86_64 0:5.7.25-1.el6                                                                                          

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.25-1.el6 mysql-community-common.x86_64 0:5.7.25-1.el6 mysql-community-libs.x86_64 0:5.7.25-1.el6

Complete!

 

 

5. 启动mysql

 

 

[root@iZ2366ycl7sZ software]# service mysqld start
Initializing MySQL database:                               [  OK  ]
Starting mysqld:                                           [  OK  ]

 

6. 查看mysql服务状态

 

 

[root@iZ2366ycl7sZ software]# service mysqld status
mysqld (pid  7036) is running...

 

7. 查看mysql 初始密码

mysql5.7之后初始密码不再默认为空

 

[root@iZ2366ycl7sZ software]# grep 'temporary password' /var/log/mysqld.log 
2019-03-29T07:09:36.375706Z 1 [Note] A temporary password is generated for root@localhost: xo%LBtyoo2MV

其中,最后的xo%LBtyoo2MV 就是密码

 

 

8. 命令行登录mysql ,并修改密码

 

登录之后 第一步必须先修改密码,

否则其他操作都执行不了。

mysql -u root -p

 

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>

 

9. 修改密码的方法:

alter user root@localhost identified by 'passwd';

# 'passwd' 里,填写你的新密码 。

新修改的密码中 必须包含 大小写字母数字及符号

 

 

End 。

 

完整的mysql相关操作,见之前的文章 http://istester.com/huanjing/134.html

 

补充,

搭建博客的文章文章 -》 http://istester.com/bushu/254.html

 

o
粉丝 0
博文 500
码字总数 0
作品 0
私信 提问
加载中
请先登录后再评论。
「a3a329fa」-「MySQL」- 安装(CentOS)

原文链接:「MySQL」- 安装(CentOS) 文章标识:「a3a329fa」 本笔记将整理在 CentOS 中安装 MySQL 数据库的方法,以及可能会遇到的问题。 CentOS 7 and MySQL 5.7 How to install MySQL 5....

k4nz
04/28
0
0
腾讯云CentOS7.0使用yum安装mysql

背景: 今天才申请了腾讯云+校园计划的1元服务器,(http://www.qcloud.com/event/qcloudSchool)安装了Centos7.0,在安装mysql的时候,使用 来查找yum源中是否有mysql,结果如下: 总之是看...

尧山少侠
2015/12/23
12
3
linux下安装mysql数据库

由于本人要在CentOS上部署一个Java项目,这个项目里面要对数据库进行操作,所以第一件事情就是安装数据库啦!现在本人将来带领你们一步一步实现MySQL数据库的安装。 首先,在CentOS下,我们可...

osc_0m4ypdo1
2018/07/11
2
0
腾讯云centos7.2搭建mysql7.5

mysql 安装不太熟悉自动安装mysql后的目录结构,所以记录下过程.参考(非常好用): https://blog.csdn.net/a774630093/article/details/79270080 执行了wget http://repo.mysql.com/mysql-comm...

osc_vnpeszfw
2019/01/05
3
0
腾讯云CentOS7.0使用yum安装mysql

背景: 今天才申请了腾讯云+校园计划的1元服务器,(http://www.qcloud.com/event/qcloudSchool)安装了Centos7.0,在安装mysql的时候,使用 来查找yum源中是否有mysql,结果如下: 总之是看...

尧山少侠
2015/12/23
54
3

没有更多内容

加载失败,请刷新页面

加载更多

Linux系统检查用户账户到期时间

如果你在 Linux 上启用了密码策略。密码必须在到期前进行更改,并且登录到系统时会收到通知。如果你很少使用自己的帐户,那么可能由于密码过期而被锁定。在许多情况下,这可能会在无需密码登...

老孟的Linux私房菜
9分钟前
0
0
关于南京哪里有开餐饮费发票?

关于南京哪里有开餐饮费发票?聚焦餐饮行业,谈话〖18 7一電一7 5 3 8一徴一3331〗研究院昨发布数据显示,今年上半年,全国餐饮行业招聘需求增长46.18%,平均月薪6387元.随着餐饮行业的快速...

点击fojewio
42分钟前
7
0
android studio 4.0 打开DDMS

1、先找到AndroidStudio配置的SDK路径; 2、在SDK的/tools/路径下有个monitor.bat 的批处理文件; 3、鼠标连续点击两下monitor.bat这个批处理文件,在屏幕上会打开一个类似CMD的命令行中输入...

chenhongjiang
44分钟前
10
0
如何在Android中使用SharedPreferences来存储,获取和编辑值

问题: Closed . 已关闭 。 This question needs to be more focused. 这个问题需要更加集中。 It is not currently accepting answers. 它当前不接受答案。 Learn more . 了解更多 。 Want...

fyin1314
54分钟前
6
0
【JDK1.8】LinkedList源码分析

LinkedList的特性 LinkedList内部使用双向链表作为存储结构,LinkedList可以理解为链表的扩展对象,封装了常用的和非常用的操作链表的方法。以及在通过索引获取元素时的简单优化,通常Linke...

XuePeng77
今天
36
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部