在实际应用中,大多数公司一般都会采用编译安装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,安装
[[email protected] local]#groupadd mysql
[[email protected] mysql-5.6.22]#seradd -g mysql mysql
[[email protected] local]#Tar -xvf mysql-5.6.22.tar.gz
[[email protected] local]#cd /mysql-5.6.22
[[email protected] mysql-5.6.22]#kdir /usr/local/mysql --创建安装路径
[[email protected] mysql-5.6.22]#kdir /usr/local/mysql/data ---创建数据库文件路径
[[email protected] 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安装即可。
[[email protected] mysql-5.6.22]#ake && make install
mysql会默认安装在指定的/usr/local/mysql目录
3,初始化数据
[[email protected] mysql-5.6.22]#d /usr/local/mysql
[[email protected] 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数据库运行环境配置
[[email protected] local]#cd /usr/local/mysql
[[email protected] mysql]#cp support-files/my-default.cnf /etc/my.cnf
[[email protected] mysql]#chown mysql:mysql /etc/my.cnf
[[email protected] mysql]#chmod -R 700 /etc/my.cnf
[[email protected] mysql]#cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]#chmod -R 700 /etc/init.d/mysqld
[[email protected] mysql]#chown mysql:mysql /etc/init.d/mysqld
[[email protected] mysql]#chown mysql:mysql /usr/local/mysql
[[email protected] mysql]#echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
[[email protected] mysql]#source /etc/profile
[[email protected] mysql]#vi /etc/my.cnf --修改成一些内容
5,启动mysql服务
[[email protected] mysql]#/etc/init.d/mysqld start