在实际应用中,大多数公司一般都会采用编译安装mysql
下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz/
系统环境:CentOS 6.7 finall
1,安装所需要的依赖包
yum install -y ncurses-devel.x86_64
yum install -y cmake.x86_64
yum install -y libaio.x86_64
yum install -y bison.x86_64
yum install -y gcc-c++.x86_64
如果不能yum安装,可以挂在光盘或找到对应的安装包安装即可。
2,安装
[root@localhost local]#groupadd mysql
[root@localhost mysql-5.6.22]#seradd -g mysql mysql
[root@localhost local]#Tar -xvf mysql-5.6.22.tar.gz
[root@localhost local]#cd /mysql-5.6.22
[root@localhost mysql-5.6.22]#kdir /usr/local/mysql --创建安装路径
[root@localhost mysql-5.6.22]#kdir /usr/local/mysql/data ---创建数据库文件路径
[root@localhost mysql-5.6.22]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1-DMYSQL_UNIX_ADDR==/usr/local/mysql/mysql.sock-DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
正常情况下回顺利完成,如果出现报错,请根据实际错误查找问题的所在原因。
然后make,make install安装即可。
[root@localhost mysql-5.6.22]#ake && make install
mysql会默认安装在指定的/usr/local/mysql目录
3,初始化数据
[root@localhost mysql-5.6.22]#d /usr/local/mysql
[root@localhost mysql-5.6.22]#scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data--defaults-file=/usr/local/mysql/my.cnf
等待初始化完成数据之后,按照说明文档操作。
4,mysql数据库运行环境配置
[root@localhost local]#cd /usr/local/mysql
[root@localhost mysql]#cp support-files/my-default.cnf /etc/my.cnf
[root@localhost mysql]#chown mysql:mysql /etc/my.cnf
[root@localhost mysql]#chmod -R 700 /etc/my.cnf
[root@localhost mysql]#cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]#chmod -R 700 /etc/init.d/mysqld
[root@localhost mysql]#chown mysql:mysql /etc/init.d/mysqld
[root@localhost mysql]#chown mysql:mysql /usr/local/mysql
[root@localhost mysql]#echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
[root@localhost mysql]#source /etc/profile
[root@localhost mysql]#vi /etc/my.cnf --修改成一些内容
[root@localhost mysql]#/etc/init.d/mysqld start
原文地址:http://karry3.blog.51cto.com/6323173/1735427