yum install -y gcc gcc-c++ make ncurses-devel bison openssl-devel zlib-devel cmake
tar zxvf mysql-5.6.10.tar.gz
cd mysql-5.6.10
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lanmp/mysql
-DMYSQL_DATADIR=/usr/local/lanmp/mysql/data
-DMYSQL_UNIX_ADDR=/usr/local/lanmp/mysql/data/mysql.sock
-DWITH_MYISAM_STORAGE_ENGINE=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
make
make install
useradd -u 27 -M -d /usr/local/lnmp/mysql mysql
groupmod -g 27 mysql //修改gid
cd /usr/local/lanmp/mysql/
chown -R mysql.mysql .
cd support-files/
cp my-default.cnf /etc/my.cnf
vim /etc/my.cnf
文件内容 一下几行的#去掉并且修改
basedir = /usr/local/lanmp/mysql datadir = /usr/local/lanmp/mysql/data port = 3306 server_id = 1 socket = /usr/local/lanmp/mysql/data/mysql.sock
cd /usr/local/lanmp/mysql/
scripts/mysql_install_db --user=mysql --basedir=/usr/local/lanmp/mysql
--datadir=/usr/local/lanmp/mysql/data/ --defaults-file=/etc/my.cnf
cd support-files/
cp mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start
chkconfig mysqld on
vim ~/.bash_profile
修改环境变量
PATH=$PATH:$HOME:/bin:/usr/local/lanmp/mysql/bin/
source ~/.bash_profile
输入mysql命令,运行成功 ,ok
mysql_secure_installation //修改mysql密码
mysql -uroot -p //登录mysql成功