linux版本:CentOS7 64位
1、下载安装包“mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz”
# 安装依赖
yum -y install perl perl-devel autoconf libaio
2、把下载的安装包移动到/usr/local/下。
3、解压
tar zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
4、复制解压后的mysql目录到系统的本地软件目录
cp mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql -r
5、添加系统mysql组和mysql用户
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
注意:Because the user is required only for ownership purposes, not login purposes, the useradd command uses the -r and -s /bin/false options to create a user that does not have login permissions to your server host. Omit these options if your useradd does not support them.
6、进入安装mysql软件目录,修改目录拥有者为mysql用户
cd mysql/
chown -R mysql:mysql ./
7、安装数据库,此处可能出现错误。
./scripts/mysql_install_db --user=mysql
FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db:
Data::Dumper
#解决方法:
yum install -y perl-Data-Dumper
8、修改当前目录拥有者为root用户
chown -R root:root ./
9、修改当前data目录拥有者为mysql用户
chown -R mysql:mysql data
============== 到此数据库安装完毕 =============
10、添加mysql服务开机自启动
添加开机启动,把启动脚本放到开机初始化目录。
cp support-files/mysql.server /etc/init.d/mysql
# 赋予可执行权限
chmod +x /etc/init.d/mysql
# 添加服务
chkconfig --add mysql
# 显示服务列表
chkconfig --list