Centos 下 mysql 安装过程

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

[[email protected] 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及其依赖

[[email protected] 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包

[[email protected] 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源

[[email protected] 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)验证是否安装成功

[[email protected] 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是启用的

[[email protected] 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

[[email protected] 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 <[email protected]>
 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

[[email protected] software]# service mysqld start
Initializing MySQL database:                               [  OK  ]
Starting mysqld:                                           [  OK  ]

6. 查看mysql服务状态

[[email protected] software]# service mysqld status
mysqld (pid  7036) is running...

7. 查看mysql 初始密码

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

[[email protected] software]# grep ‘temporary password‘ /var/log/mysqld.log
2019-03-29T07:09:36.375706Z 1 [Note] A temporary password is generated for [email protected]: 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 [email protected] identified by ‘passwd‘;

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

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

End 。

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

补充,

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

原文地址:https://www.cnblogs.com/idotest/p/10651421.html

时间: 2024-11-10 15:20:04

Centos 下 mysql 安装过程的相关文章

Centos下MySQL安装与配置

一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱不得不首先推荐的是mysql数据库了,而且Mysql数据库的第一个版本就是发行在Linux系统上的. MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司.MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内

WINDOWS系统下MYSQL安装过程中的注意事项

1.首先MySQL的安装方式有两种:一种是MSI安装方式,很简单就像安装Windows软件一样.另外一种就是ZIP安装方式.这种相对而言比较麻烦.新手推荐MSI安装方式. 安装方式有以下两种: MSI的安装包方式(相对简单):ZIP安装方式 选择安装类型:(推荐选择Typical 典型安装方式) Typical:典型安装 Custom:自定义安装 Complete:完全安装 2.MySQL配置 详细配置 detailed configuration 标准配置 standard configura

CentOS下Mysql安装调试

一.安装 yum安装:yum install -y mysql-server mysql mysql-devel 设置自启动:chkconfig mysqld on 启动MySQL:service mysqld start 设置root密码:/usr/bin/mysqladmin -u root password "123456" 安装测试:mysql -uroot -p 设置允许远程访问: mysql> grant all privileges on *.* to 'root'

CentOS下mysql安装和配置

1.卸载原有mysql [[email protected] /]# rpm -qa | grep mysql 查看该操作系统上是否已经安装了mysql数据库.有的话,我们就通过 rpm -e 命令 或者 rpm -e --nodeps 命令来卸载掉 [[email protected] /]# rpm -e mysql 在删除完以后我们可以通过 rpm -qa | grep mysql 命令来查看mysql是否已经卸载成功. 2.用yum安装mysql 通过yum的方式来进行mysql的数据库

CentOS下mysql安装

一.检查环境 # 切换root 权限 su root # 检查是否安装过mysql rpm -qa|grep mysql # 删除所有mysql yum -y remove mysql* 1.上传文件到software目录,解压并修改文件夹名称为 mysql 2.创建用户和用户组,并给mysql文件夹赋予用户组权限 2.1查看是否有mysql用户及用户组 cat /etc/passwd cat /etc/group 2.2添加用户组 groupadd mysql useradd -r -g my

centos下mysql 数据库安装、调试

博主是一个linux的初学者,决定记录学习过程中的点滴,当做一个成长记录也好,当做后来人学习的参考也罢,总之,博客就在那里,我们各取所需,只是不要让他孤独就好. 首先,持久化数据是一个程序必备的模块,恰逢博主的项目中也需要在centos操作系统上部署,所以就以安装mysql数据库开始吧.可能你觉得内容比较简单,但无所谓吧,会者谓之简单:不会者谓之难.博主只求用最简单的描述,满足“不会者”的好学. 主要分为两种方式,一种是下载安装包,然后安装:一种是通过yum命令.博主觉得通过yum命令比较简单,

centos下yum安装mysql5.6后,无法启动 MySQL Daemon failed to start

如果是全新安装应该就不会出现这个问题,升级安装的话,要运行 mysql_upgrade ,但是启动MYSQL就报错MySQL Daemon failed to start 如此就没办法运行mysql_upgrade升级MYSQL表了 因为是全新安装的数据库服务器就不管老数据了,直接把老的MYSQL数据库文件夹删除了,然后 运行 mysql_install_db 单独执行下命令,初始化mysql,test等数据库 初始化所有数据库以后,依然是无法启动,检查了MYSQL的日志发现没有权限,因为是RO

centos下mysql 最新版终于安装成功!备份一下几个关键地方

我本来只是为了搭建简单的LAMP环境,亲自动手,却发现有这么多的问题会发生.(by default7#zbphp.com) 很多地方给的安装Mysql的提示是通过yum一键安装.shell命令如下: yum install mysql yum install mysql-server yum install mysql-devel 但是,这个命令安装的mysql版本很旧,5.1.0x版本的,官网的Mysql已经是 5.6.x版本了.太旧了,记得08年的时候就出了 5.1的版本了. 坚持安装最新版

CentOS下MySQL数据库安装

前辈们总是说,要边学边记录,要总结.所以,开始把每天学到的内容一点一点记录. 复杂的理论不懂,只会目前安装,安好后就开始玩咯! 1.在官网下载相应的rpm安装包 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads 比如:我只下载了这三个. 2.鄙人就用rpm命令安装(相对较熟悉) 其实,这是应该是第3步 #rpm -ivh MySQL-client-5.6.19-1.el6.i686.rpm #rpm -ivh MySQL-d