访问MySQL的官网,进入其下载页面(http://dev.mysql.com/downloads/mysql/#downloads),选择MySQL Community Server,在“Select Platform”下拉框中选择“Oracle & Red Hat Linux 4 & 5”。
(1)MySQL-server-5.6.10-1.rhel5.x86_64.rpm:MySQL服务器;
(2)MySQL-client-5.6.10-1.rhel5.x86_64.rpm:MySQL客户端;
(3)MySQL-devel-5.6.10-1.rhel5.x86_64.rpm:Mysql开发依赖包。
将这些rpm包通过FTP上传到Linux服务器的某个目录,例如:/root/software。
也可在Linux服务器上通过wget命令取得这些rpm包,Linux命令如下:
wget
wget
3、安装MySQL服务器和客户端
3.1 安装MySQL服务器
3.1.1 安装依赖包libaio
在运行第一条安装MySQL服务器时会提示依赖包libaio.so.1没有安装,错误提示如下:
libaio.so. 1 ()(64bit)
libaio.so. 1 (LIBAIO_0. 1 )(64bit)
libaio.so. 1 (LIBAIO_0. 4 )(64bit)
需要使用yum命令快速安装依赖包libaio,运行如下命令:
运行该命令时会发现在这台云服务器上无法通过yum快速安装软件,搜索了一些资料,原来是阿里云安装的是Red Hat5.4的64位系统,但是提供的是CentOS 32位的系统。错误信息参考如下:
No
Nothing
(1)通过rpm命令查看有哪些yum包,然后进行卸载
笔者在云服务器进行的操作如下:
yum - 3.2 . 22 - 20 .el5
yum - metadata - parser - 1.1 . 2 - 3 .el5
[root@AY130221101729bc93912
warning:
[root@AY130221101729bc93912
(2)通过wget命令在163的镜像上下载CentOS的yum包
参考命令如下:
wget
wget
说明:可能版本会有一些不同,请大家在http://mirrors.163.com/centos/5/os/x86_64/CentOS/下查找yum-3xxx开头、yum-metadata开头和yum-fastestmirror开头的rpm包下载。
找一个CentOS的包资源配置库,名为CentOS-Base.repo,放到/etc/yum.repos.d/路径:
[root@AY130221101729bc93912
-- 2013 - 02 - 22
Resolving
Connecting
HTTP
Length:
Saving
100 % [ ==========================================================================================> ]
2013 - 02 - 22
(5)生成缓存文件到/var/cache/yum目录
Loaded
Determining
addons
addons / filelists_db
addons / other_db
base
……
base
Metadata
(6)安装依赖包libaio
第(5)步做完后,此时可以成功运行yum install libaio命令,参考执行情况如下:
Loaded
Loading
Setting
Resolving
……
Complete
3.1.2 安装MySQL Server的rpm包
Preparing
2013 - 02 - 22
…….
A
2013 - 02 - 22
2013 - 02 - 22
……
3.2 安装MySQL客户端
3.3 安装MySQL开发依赖包
3.4 MySQL的几个重要目录
(1)数据库目录
/var/lib/mysql/
(2)配置文件
/usr/share/mysql(mysql.server命令及配置文件)
(3)相关命令
(4)启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
mysql:
3.5 启动MySQL
ERROR
3.6 登录MySQL
使用mysql命令登录MySQL服务器,运行MySQL的命令时,会提示需要设置root用户密码,提示信息如下:
Enter
Welcome
Your
Server
Copyright
Oracle
affiliates.
owners.
Type
mysql >
ERROR
可使用SET PASSWORD命令修改root用户的密码,参考如下:
Query
mysql >
+--------------------+
|
+--------------------+
|
|
|
|
+--------------------+
3.7 设置开机自启动
Active
Proto
tcp
tcp
tcp