CentOS6.5 解压安装 二进制分发版 mysql-5.5.49-linux2.6-x86_64.tar.gz

环境:CentOS 6.5 64位

1、下载安装包 http://dev.mysql.com/downloads/mysql/5.5.html#downloads

http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz

 

2、安装 MySQL

注意:安装包统一放到 /usr/local/src 目录下。

# 卸载老版本MySQL

rpm -e mysql
yum -y remove php-mysql
yum -y remove mysql-server mysql

# 禁用SeLinux

setenforce 0

# 安装依赖库

yum install -y gcc gcc-c++ kernel-devel ntp vim-enhanced flex bison autoconf make automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel  libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel pcre-devel libtool-libs gd file patch mlocate diffutils readline-devel glibc-devel glib2-devel libcap-devel

yum install -y libaio

# 移动到安装目录

sudo mkdir /usr/local/mysql
cd /usr/local/src
tar -xzvf ./mysql-5.5.49-linux2.6-x86_64.tar.gz
sudo mv ./mysql-5.5.49-linux2.6-x86_64/* /usr/local/mysql

# 新建用户

sudo groupadd mysql
sudo useradd -g mysql -s /usr/sbin/nologin mysql   #不让mysql用户直接登录
sudo chown -R mysql:mysql /usr/local/mysql/

# 复制配置文件

cp /usr/local/mysql/support-files/my-medium.cnf  /etc/my.cnf

# 设置权限

chmod +x /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql

# 配置开机自动启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
chkconfig --list mysqld #查看是否已应用上

# 添加MySQL的软链接以适应init脚本

ln -sv /usr/local/mysql/bin/mysql /usr/sbin/mysql
ln -sv /usr/local/mysql/bin/mysqladmin /usr/sbin/mysqladmin
ln -sv /usr/local/mysql/bin/mysqldump /usr/sbin/mysqldump

# 修改配置文件

vim /etc/my.cnf

# 在 [mysqld] 节点中添加

datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp

# 保存退出

# 初始化数据库

sudo /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

# 修改root密码

/usr/local/mysql/bin/mysqladmin -u root -p password "123456"

 

3、配置防火墙

# 配置防火墙,开启3306端口

vim /etc/sysconfig/iptables

# 添加如下规则到22端口这条规则的下面即可

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

# 重启防火墙

/etc/init.d/iptables restart  # 或  service iptables restart

# 启动MySQL

service mysqld start  # 或 /etc/init.d/mysqld start

 

4、测试MySQL是否启动

# 查看是否有mysql进程

ps -ef | grep mysql

# 查看是否有mysql端口

netstat -ntlp | grep 3306

# 测试mysql,mysqladmin,mysqldump命令是否能正常使用

# 读取MySQL的版本信息

mysqladmin version

到此MySQL编译安装完成。

posted @ 2016-07-19 07:36  52php  阅读(5252)  评论(0编辑  收藏  举报