1. 通过命令下载:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
注意:wget会将其下载到当前目录,若需指定目录:wget -P XX目录 http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
若无安装wget,执行安装命令:yum -y install wget
2. 解压,并将解压后的mysql文件夹复制到指定路径下:
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
3. 添加用户组和用户:
groupadd mysql
useradd -g mysql mysql
4.
cd /usr/local/mysql/<br>mkdir ./data/mysql
chown -R mysql:mysql ./ # 授权
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
#修改启动脚本
vi /etc/init.d/mysqld
#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql #注意,该文件较大,进入编辑模式后下拉文件,找到basedir和datadir选项进行修改
#启动服务
service mysqld start
#设置开机启动:
chkconfig mysqld on
#设置mysql命令全局可用:
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql