Centos 下 mysql 安装过程
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
Centos 下 mysql 安装过程的更多相关文章
- CentOS下Mysql安装教程
CentOS下Mysql安装教程 本人学习Linux时使用的是CentOs5.5版本,在该环境中,Mysql的安装方法有很多种,下面我只讲我这次成功了的方法,作为一个记录,供大家参考,同时给自己做一个 ...
- Linux下mysql安装过程
到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (g ...
- Linux下Java开发环境搭建—CentOS下Mysql安装教程
本人学习Linux时使用的是CentOs5.5版本,在该环境中,Mysql的安装方法有很多种,下面我只讲我这次成功了的方法,作为一个记录,供大家参考,同时给自己做一个笔记. MySQL下载 1.进入网 ...
- Centos 下mysql安装配置
一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake,从http://www.cmake ...
- CentOS下MySQL安装失败,报socket '/tmp/mysql.sock错误解决方法
1.在centos里安装mysql数据库后,登录时提示‘/tmp/mysql.sock’ 第一种解决办法:采用ln链接方式进行处理 ln -s /var/lib/mysql/mysql.sock /t ...
- WINDOWS系统下MYSQL安装过程中的注意事项
1.首先MySQL的安装方式有两种:一种是MSI安装方式,很简单就像安装Windows软件一样.另外一种就是ZIP安装方式.这种相对而言比较麻烦.新手推荐MSI安装方式. 安装方式有以下两种: MSI ...
- CentOS下mysql安装和配置
1.卸载原有mysql [root@iZ25ka6ra32Z /]# rpm -qa | grep mysql 查看该操作系统上是否已经安装了mysql数据库.有的话,我们就通过 rpm -e 命令 ...
- CentOS下Mysql安装调试
一.安装 yum安装:yum install -y mysql-server mysql mysql-devel 设置自启动:chkconfig mysqld on 启动MySQL:service ...
- win10下mysql安装过程中遇到的各种坑
前几天重装系统,又要下回来mysql,但没想到还是遇到了许多麻烦,翻了十多篇博文才搞定,写个总结出来方便以后不要重复踩坑,也给大家参考参考. 1.下载与安装 这个没什么好说的,下载地址网上一大堆,安装 ...
随机推荐
- Android SD卡上文件
1. 得到存储设备的目录:/SDCARD(一般情况下) SDPATH=Environment.getExternalStorageDirectory()+"/"; 2. 判断SD卡 ...
- 交叉编译 Cross-compiling for Linux
@(134 - Linux) Part 1 交叉编译简介 1.1 What is cross-compiling? 对于没有做过嵌入式编程的人,可能不太理解交叉编译的概念,那么什么是交叉编译?它有什么 ...
- Qt消息机制和事件、事件过滤
一,事件 事件(event)是由系统或者 Qt 本身在不同的时刻发出的.当用户按下鼠标.敲下键盘,或者是窗口需要重新绘制的时候,都会发出一个相应的事件.一些事件在对用户操作做出响应时发出,如键盘事件等 ...
- 1 python使用networkx或者graphviz,pygraphviz可视化RNN(recursive)中的二叉树
代码地址https://github.com/vijayvee/Recursive-neural-networks-TensorFlow 代码实现的是结构递归神经网络(Recursive NN,注意, ...
- C++ 重载 重写 重定义
重写:存在于类的继承,修饰符是virtual,函数的参数个数,顺序,类型,均相同. 重载:函数的参数列表,类型,顺序不相同. 重定义:对父类的函数进行屏蔽,参数列表可以不相同,没有virtual修饰
- nginx+php+swoole安装记录
领了台阿里服务器1vCPU 1G,做下测试研究. 系统 centos7,使用yum安装. Nginx yum install nginx ##开启nginx service nginx start 安 ...
- cetnos7下openresty使用luarocks 进行lua的包管理
先安装一下包管理工具 yum install luarocks lua-devel -y luarocks install lpack ln -s /usr/lib64/lua /usr/local/ ...
- C语言支持的四种变量存储类型
http://blog.csdn.net/zhandoushi1982/article/details/5425835 一)auto:auto称为自动变量(局部变量).局部变量是指在函数内部说明的变量 ...
- 【[SCOI2013]摩托车交易 】
倍增什么的最慢了,常数太大了 我们可以上树剖啊 但是如果用树剖来查询树上两点之间的最小边权的话,可能只能在上一棵线段树? 那也太\(naive\)了,尽管倍增常数大,但是还是比两个\(log\)快的 ...
- 【小M的作物】
这是一道我好像没写过的最小割 这道题如果没有那\(m\)条限制,我们完全可以贪心来做 但是硬要用网络流怎么办 可以转化为最小割模型 我们将源点\(S\)表示为耕地\(A\),汇点\(T\)表示为耕地\ ...