1、创建用户安装依赖包上传软件包
[[email protected] ~]# useradd -s /sbin/nologin -M mysql #<==创建用户
[[email protected] app]# yum install libaio* perl-devel -y #<==安装依赖包
[[email protected] app]# mkdir -p /home/app #<==创建软件存放目录
[[email protected] app]# cd /home/app #<==切换目录上传文件
[[email protected] app]# rz
2、解压移动安装包
[[email protected] app]# tar zvxf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz #<==解压安装包
[[email protected] app]# mkdir /app #<==创建软件安装目录
[[email protected] app]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /app/mysql-5.6.36 #<==移动安装包目录至软件安装目录
[[email protected] app]# ln -s /app/mysql-5.6.36 /app/mysql #<==创建软连接
3、初始化数据库
[[email protected] app]# cp /app/mysql/support-files/my-default.cnf /etc/my.cnf #<==复制配置文件
[[email protected] app]# chown -R mysql.mysql /app/mysql #<==更改目录权限
[[email protected] app]# chmod -R 1777 /tmp/ #<==更改权限
[[email protected] data]# /app/mysql/scripts/mysql_install_db --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data #<==初始化数据库
[[email protected] data]# cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld #<==复制启动脚本至开机启动目录
[[email protected] data]# chmod +x /etc/init.d/mysqld #给启动脚本添加执行权限
[[email protected] data]# sed -i ‘s#/usr/local/mysql#/app/mysql#g‘ /etc/init.d/mysqld /app/mysql/bin/mysqld_safe #<==替换默认安装位置路径
[[email protected] data]# chkconfig --add mysqld #<==加入开机启动项
[[email protected] data]# chkconfig mysqld on #<==设置开机启动
[[email protected] data]# chkconfig --list mysqld #<==查看设置是否生效
[[email protected] data]# echo "export PATH=/app/mysql/bin:PATH">>/etc/profile #<==添加环境变量
[[email protected] data]# source /etc/profile #<==生效环境变量
[[email protected] data]# /etc/init.d/mysqld start #<==启动程序
[[email protected] data]# mysql #<==登录测试成功
原文地址:http://blog.51cto.com/11956937/2096600