linux编译安装mysql5.6.20

cmake编译安装mysql的方法:
#useradd -M mysql -s /sbin/nologin
#yum install -y cmake
#tar zxvf mysql-5.6.35.tar.gz
#cd mysql-5.6.35

创建数据存放目录
#mkdir /data/mysql

创建用户及用户组并指定之上的目录,用户及用户组
#useradd -M mysql -s /sbin/nologin
#chown -R mysql.mysql /data/mysql

预编译
#cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
-DMYSQL_DATADIR=/data/mysql\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_ARCHIVE_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DENABLED_LOCAL_INFILE=1\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DEXTRA_CHARSETS=all\
-DMYSQL_TCP_PORT=3306\
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock\
-DWITH_DEBUG=0

编译安装
#make && make install

编译出错,删除下面文件,重新编译安装。
#rm -f CMakeCache.txt
#make && make install

拷备配置文件及启动文件到指定目录下
#cp support-files/my-medium.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/init.d/mysqld

修改配置文件my.cnf
加入basedir=/usr/local/mysql
修改启动脚本mysqld
加入或修改
basedir=/usr/local/mysql
datadir=/data/mysql
#chmod 755 /usr/local/mysql/scripts/mysql_install_db
#chown -R mysql.mysql /usr/local/mysql/

初始化权限
#/usr/local/mysql/scripts/mysql_install_db
–user=mysql –basedir=/usr/local/mysql/ –datadir=/data/mysql/

将mysql服务命令目录加入path环境变量中。
#echo “export PATH=$PATH:/usr/local/mysql/bin” >>/etc/profile
#source /etc/profile

修改mysql用户登录密码
#/usr/local/mysql/bin/mysqladmin -uroot password 123456
#/usr/local/mysql/bin/mysql -uroot -p123456