CentOS 6.6二进制包安装MySQL5.5

1. 背景
  * MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件。
  * MySQL是一种关系数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。
  * MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。

2. 选择的理由
  * 支持多种平台[AIX、FreeBSD、HP-UX、Linux、Mac OS、OpenBSD、Solaris、Windows......]
  * 支持并提供多语言API
  * 开源,采用了 GPL协议,可以修改源码来开发自己的 MySQL 系统
  * 支持标准SQL语句
  * 支持多种存储引擎

3. 环境
[root@mysql ~]# cat /etc/RedHat-release 
CentOS release 6.6 (Final)
[root@mysql ~]# uname -r
2.6.32-504.el6.x86_64

4. 安装
 * 进入包下载目录
[root@mysql ~]# cd /usr/local/src/

* 下载MySQL二进制包[mysql-5.5.53-linux2.6-x86_64.tar.gz]
[root@mysql src]# wget

* 解包
[root@mysql src]# tar zxf mysql-5.5.53-linux2.6-x86_64.tar.gz

* 移动到mysql安装目录
[root@mysql src]# mv mysql-5.5.53-linux2.6-x86_64 /usr/local/mysql-5.5.53

* 创建mysql软链接

[root@mysql src]# ln -s /usr/local/mysql-5.5.53 /usr/local/mysql

* 进入mysql目录
[root@mysql src]# cd /usr/local/mysql

* 复制mysql配置文件到指定位置
[root@mysql mysql]#  \cp support-files/my-medium.cnf /etc/my.cnf

* 创建mysql服务用户
[root@mysql mysql]# useradd -r -s /sbin/nologin -M mysql

* 创建mysql数据目录
[root@mysql mysql]# mkdir /data/mysql -p

* 更改数据目录所属用户与组
[root@mysql mysql]# chown mysql.mysql /data/mysql

* mysql初始化
[root@mysql mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

Installing MySQL system tables...
170325  3:12:16 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170325  3:12:16 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.53-log) starting as process 8023 ...
OK
Filling help tables...
170325  3:12:16 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170325  3:12:16 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.53-log) starting as process 8031 ...
OK
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h mysql password 'new-password'
 
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
 
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
 
See the manual for more instructions.
 
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
 
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
 
Please report any problems at

看到如上两个OK就证明初始化成功

5. 创建启动脚本
 * 复制启动脚本到service 服务管理目录下[ /etc/init.d ]
[root@mysql mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

* 修改mysql启动脚本 [ /et/init.d/mysqld ]
basedir=/usr/local/mysql
datadir=/data/mysql

* 添加进service服务管理
[root@mysql mysql]# chkconfig --add mysqld

6. 服务启动测试

CentOS 6.6二进制包安装MySQL5.5

mysql启动成功

7. 服务连接测试
[root@mysql mysql]# /usr/local/mysql/bin/mysql

CentOS 6.6二进制包安装MySQL5.5

通过mysql客户端连接成功

8. 设置root密码
[root@mysql mysql]# /usr/local/mysql/bin/mysqladmin -u root password '123456'

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2f37dbef038b7c28691657db2245a2fd.html