1.下载二进制安装包:
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
mkdir -p /usr/local/mysql
mkdir -p /data/mysql/data
3.解压文件到basedir目录
tar -z'x'v'f mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz /usr/local/mysql
4.创建mysql专用用户和组,并对相应目录赋权限
groupadd mysql useradd mysql -g mysql
chown -R mysql.mysql /data/mysql/data
chown -R mysql.mysql /usr/local/mysql
5.执行安装文件
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
6.复制配置文件cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
并修改文件中参数
basedir=/usr/local/mysql
datadir=/data/mysql/data
7.启动:
service mysqld start
8.mysql的命令添加的环境变量中在文件末尾(G)添加vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
使profile文件生效
9.设置开机启动mysqlsource /etc/profile
吧启动文件放在系统开机初始化目录下
增加执行权限cp /usr/local/mysq/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
添加服务
chkconfig --add mysqld chkconfig --list mysqld
遇到的问题:
1.执行scripts/mysql_install_db 命令时,报错:缺少perl的一个module Data::Dumper
用CPAN安装 首先安装cpan:sudo yum -y install perl-CPAN
进入cpan:perl -MCPAN -e shell
再cpan命令行下执行:install Data::Dumper
2.执行mysql_install_db文件时候报错:应该是权限问题
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
原因:chown文件是在在执行完mysql_install_db文件后操作的
解决:重新执行mysql_install_db