1.上传源码包
http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz/from/http://cdn.mysql.com/
2.yum方式安装相关依赖包
yum -y install cmake bison git ncurses-devel gcc gcc-c++
3.创建一个用户名为mysql的用户并加入mysql用户组
# groupadd mysql
# useradd -g mysql mysql
4.解压mysql-5.6.38.tar.gz,并且创建mysql安装目录和数据库文件存放目录
# tar zxvf mysql-5.6.38.tar.gz
# mkdir /usr/local/mysql
# mkdir /usr/local/mysql/data
# cd mysql-5.6.38/
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1
make && make install
5.安装完之后,清除临时文件
make clean
6.修改目录属主权限
chown -R mysql:mysql /usr/local/mysql/data/
chown -R mysql:mysql /usr/local/mysql/
配置启动脚本
cp /usr/local/mysql//mysql.server /etc/rc.d/init.d/mysql
修改配置文件(加强mysql命令的执行)
vim /etc/profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
变量生效:
soure /etc/profile
Mysql服务启动报错
[root@localhost ~]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
解决: rm -rf /var/lib/mysql/*