CentOS 6.5下安装MySQL 5.6.21

Linux中使用最广泛的数据库就是MySQL,使用在线yum的方式安装的版本落后MySQL网站好几个小版本,本节亲自测试安装新版的MySQL。


测试机器环境:

VMware Workstation 10 虚拟机

内存:1G

Linux版本:CentOS MinimalCD 6.5

JAVA:JAVA_HOME=/opt/jdk


安装mysql前需要查询系统中含有的有关mysql的软件。

rpm -qa | grep -i mysql  //grep -i是不分大小写字符查询,只要含有mysql就显示


屏幕显示:

mysql-libs-5.1.71-1.el6.i686  //它是好几个软件的依赖,其中在mini版本中postfix软件依赖mysql-libs,网络上很多建议都是直接删除,
yum remove mysql-libs 或者 rpm -e --nodeps mysql-libs-5.1.71-1.el6.i686,总觉得这样做不好。
查找mysql官方资料,得到安装方法是用MySQL-shared-compat将mysql-libs-5.1.71-1.el6.i686替换为同版本后在安装mysql。

下载mysql地址:http://dev.mysql.com/downloads/mysql/

CentOS是RedHatLinux系列的,因此选择RedHatLinux(见红线地方),网页会自动变成RedHatLinux有关的mysql下载:

需要下载2个内容,一个是MySQL-5.6.21-1.el6.i686.rpm-bundle.tar,这个是几个程序的合集包,另一个是 MySQL-shared-compat-5.6.21-1.el6.i686.rpm,这个是软件包包括MySQL 3.23和MySQL 4.0的共享库。如果你安装了应用程序动态连接MySQL 3.23,但是你想要升级到ySQL 4.0而不想打破库的从属关系,则安装该软件包而不要安装MySQL-shared。从MySQL 4.0.13起包含该安装软件包。

将2个文件上传到CentOS中,解压MySQL-5.6.21-1.el6.i686.rpm-bundle.tar。

#tar xvf MySQL-5.6.21-1.el6.i686.rpm-bundle.tar
MySQL-client-5.6.21-1.el6.i686.rpm
MySQL-devel-5.6.21-1.el6.i686.rpm
MySQL-shared-5.6.21-1.el6.i686.rpm
MySQL-test-5.6.21-1.el6.i686.rpm
MySQL-server-5.6.21-1.el6.i686.rpm
MySQL-embedded-5.6.21-1.el6.i686.rpm
#ls -l
total 415068
-rw-r--r--. 1 root root  210442240 Nov 11 11:12 MySQL-5.6.21-1.el6.i686.rpm-bundle.tar
-rw-r--r--. 1 7155 wheel  17813608 Sep 12 16:25 MySQL-client-5.6.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 wheel   3131328 Sep 12 16:25 MySQL-devel-5.6.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 wheel  83106000 Sep 12 16:25 MySQL-embedded-5.6.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 wheel  54611632 Sep 12 16:26 MySQL-server-5.6.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 wheel   1878756 Sep 12 16:27 MySQL-shared-5.6.21-1.el6.i686.rpm
-rw-r--r--. 1 root root    4141488 Nov 18 14:42 MySQL-shared-compat-5.6.21-1.el6.i686.rpm
-rw-r--r--. 1 7155 wheel  49887932 Sep 12 16:27 MySQL-test-5.6.21-1.el6.i686.rpm

安装MySQL-shared-compat替换mysql-libs,如果不替换,在删除mysql-libs,会提示postfix依赖于mysql-libs:

# rpm -i MySQL-shared-compat-5.6.21-1.el6.i686.rpm
# rpm -qa | grep -i mysql
mysql-libs-5.1.71-1.el6.i686
MySQL-shared-compat-5.6.21-1.el6.i686
# yum remove mysql-libs

测试MySQL-server安装,提示需要安装perl:

# rpm -ivh --test MySQL-server-5.6.21-1.el6.i686.rpm
# yum install perl

安装MySQL-server,MySQL-client:

# rpm -ivh  MySQL-server-5.6.21-1.el6.i686.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
………………
………………
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in ‘/root/.mysql_secret‘.
You must change that password on your first connect,
no other statement but ‘SET PASSWORD‘ will be accepted.
See the manual for the semantics of the ‘password expired‘ flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
  /usr/bin/mysql_secure_installation
………………
………………
# rpm -ivh  MySQL-client-5.6.21-1.el6.i686.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

在安装MySQL-server,见上面的一段话,大意是全新安装设置的root密码在/root/.mysql_secret中,这是一个随机密 码,你需要运行/usr/bin/mysql_secure_installation,删除anonymous用户。当然不建议用root用户来运 行,rpm包已经建了一个mysql用户,可以使用这个用户:

#more .mysql_secret
# The random password set for the root user at Tue Nov 18 22:57:46 2014 (local t
ime): NljqL63OYlGo5cqy    <– 得到root访问mysql的密码:NljqL63OYlGo5cqy
# service mysql start
Starting MySQL... SUCCESS!
# /usr/bin/mysql_secure_installation --user=mysql
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we‘ll need the current
password for the root user.  If you‘ve just installed MySQL, and
you haven‘t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):    <–使用刚才得到的root的密码 NljqL63OYlGo5cqy
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer ‘n‘.

Change the root password? [Y/n] y   <– 是否更换root用户密码,输入y并回车,强烈建议更换
New password:      <– 设置root用户的密码
Re-enter new password:    <– 再输入一次你设置的密码
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y   <– 是否删除匿名用户,生产环境建议删除,所以输入y并回车
 ... Success!

Normally, root should only be allowed to connect from ‘localhost‘.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y    <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
 ... Success!

By default, MySQL comes with a database named ‘test‘ that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y    <– 是否删除test数据库,输入y并回车
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y   是否重新加载权限表,输入y并回车
 ... Success!

All done!  If you‘ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up...

至此,MySQL已经安装完成,最后看一下是否已将MySQL加到开机服务里:

#  chkconfig
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
blk-availability        0:off   1:on    2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
ip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:off
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
iscsi           0:off   1:off   2:off   3:on    4:on    5:on    6:off
iscsid          0:off   1:off   2:off   3:on    4:on    5:on    6:off
lvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:off
mdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:off
multipathd      0:off   1:off   2:off   3:off   4:off   5:off   6:off
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off   <-看到这个OK了
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
restorecond     0:off   1:off   2:off   3:off   4:off   5:off   6:off
rsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:off
saslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
udev-post       0:off   1:on    2:on    3:on    4:on    5:on    6:off

MySQL安装后涉及的目录如下:

目录 目录中的内容
/usr/bin 客户端程序和脚本
/usr/sbin Mysqld服务器
/var/lib/mysql 数据库的日志文件
/usr/share/info 信息格式手册
/usr/share/man Unix 手册页
/usr/include/mysql 包括 (标题) 的文件
/usr/lib/mysql mysql的lib包
/usr/share/mysql 杂项的支持文件,包括错误消息) 字符设置的文件,示例配置文件,SQL 数据库安装
/usr/share/sql-bench 基准

现在好了,可以测试你的MySQL了。

--------------------------------------分割线 --------------------------------------

Ubuntu 14.04下安装MySQL http://www.linuxidc.com/Linux/2014-05/102366.htm

《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF http://www.linuxidc.com/Linux/2014-03/98821.htm

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL http://www.linuxidc.com/Linux/2014-05/102351.htm

Ubuntu 14.04下搭建MySQL主从服务器 http://www.linuxidc.com/Linux/2014-05/101599.htm

Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群 http://www.linuxidc.com/Linux/2013-11/93019.htm

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb http://www.linuxidc.com/Linux/2013-08/89270.htm

MySQL-5.5.38通用二进制安装 http://www.linuxidc.com/Linux/2014-07/104509.htm

--------------------------------------分割线 --------------------------------------

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-01/111413.htm

时间: 2024-10-07 01:31:24

CentOS 6.5下安装MySQL 5.6.21的相关文章

CentOS 6.4下安装MySQL 5.6.22

本文详细介绍在CentOS 6.4下安装MySQL 5.6.22的过程,供需要的朋友学习参考. 一.下载MySQL 安装包 1)http://dev.mysql.com/downloads/mysql/ 打开网址: Select Platform: 选择 Linux-Generic 选择选择 Linux - Generic (glibc 2.5) (x86, 64-bit), RPM   进行下载: linux 下下载: wget  http://cdn.mysql.com/Downloads/

CentOS 6.4下安装MySQL后重置root密码方法

本人在CentOS 6.4上安装万mysql后,无法通过root进入,因为安装的时候,并没有设置root密码,似乎有个初始随机密码,但是不记得了,太麻烦,直接重置root密码. 使用rpm包安装完mysql后,按照一下步骤重置root密码: 启动mysql:#/etc/init.d/mysql start 启动成功后查看mysql进程信息,获取mysqld_safe的安装目录(非常关键):#ps -ef | grep -i mysqlroot 3466 1 0 01:45 pts/1 00:00

CentOS 5.5下安装MySQL 5.5全过程分享

打开终端 切换到根目录 [shell@localhost ~]# su -安装Mysql5.5之前先卸载CentOS自带的Mysql5.0. [root@localhost ~]# yum remove mysql 安装cmake 下载cmake源码包cmake-2.8.5.tar.gz [root@localhost ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz编译安装[[email protected]]# tar x

Linux CentOS 7环境下安装MySQL

在CentOS 7中默认安装有MariaDB,但是我们需要的是MySQL,安装MySQL可以覆盖MariaDB. (注:MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险.MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品.) 首先需要安装MySQL的Yum Repository. (注:

centos 6.5下安装mysql

1.检测系统是否已经安装过mysql或其依赖,若已装过要先将其删除,否则第4步使用yum安装时会报错: 1 # yum list installed | grep mysql 2 mysql-libs.i686 5.1.71-1.el6 @anaconda-CentOS-201311271240.i386/6.5 3 # yum -y remove mysql-libs.i686 2.从mysql的官网下载mysql57-community-release-el6-5.noarch.rpm(注意

CentOS 6.5下安装MySql 5.7

环境: 1).软硬件:E6420双核CPU,8G内存,1T硬盘 2).虚拟机下 CentOS 6.5 64位 最小化桌面安装 (1个CPU,2个核心, 2G内存,35G硬盘) 3).安装包放在/usr/local/src/LAMP目录下 1.yum安装编译环境 [[email protected] ~]# yum -y install make gcc gcc-c++ zlib-devel libaio 2.配置防火墙,开启  80  端口.  3306  端口 [[email protecte

centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记

目录[-] 过程 1.安装RVM 2.利用rvm安装 Ruby 1.9.3 并设为默认 3.安装rails 4.安装依赖包 5.为Rails生成cookies秘钥 6.安装redmine 7. 在WEBrick服务上测试Redmine是否安装成功 8.配置Redmine在Nginx上运行 系统:centos 6.5 x64 redmine 版本:3.1.0 ruby 版本: 2.2.3 rails 版本 : 4.2 过程 1.安装RVM 安装公钥 [root@localhost ~]# curl

CentOS 6.8下安装MySQL 5.6.33

此处操作,包含MySQL的客户端及服务端. MySQL下载地址: http://dev.mysql.com/downloads/mysql/5.6.html 1 MySQL-5.6.33-1.linux_glibc2.5.x86_64.rpm-bundle.tar 下载到本地,将其解压,得到如下文件: 1 -rw-r--r--. 1 7155 31415 23514633 Aug 29 18:11 MySQL-client-5.6.33-1.linux_glibc2.5.x86_64.rpm 2

Linux(CentOS 6.5) 下安装MySql 5.7.18 二进制版本粗浅攻略

鉴于Linux和mysql因不同版本,安装方式也不同,所以在阅读本攻略前,请确保各位同学的版本和我的Linux.MySql 版本一致. 如果不一致,只能参考. 我的版本: Linux CentOS 6.5 MySql 5.7.18 特别提醒:MySq 5.7和5.6在安装方式上有大不同,所以5.6的同学不要看这个攻略. 一.程序准备 1.进入 https://dev.mysql.com/downloads/mysql/ 选择 Linux-Generic,根据系统是64位还是32位选择下载的包.t