安装依赖包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl*
从本地上传Mysql压缩包
put mysql-5.6.16.tar.gz
tar xf mysql-5.6.16.tar.gz
cd mysql-5.6.16
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
初始化mysql数据库
cd /usr/local/mysql
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig mysqld on
填写数据存放路径,不写可能导致数据库无法启动
vim /etc/my.cnf
datadir=/usr/local/mysql/data
:wq
service mysqld start
添加路径到PATH中
vim /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH
source /etc/profile
service mysqld start
mysql -uroot
给数据库root用户设置密码
mysql> SET PASSWORD = PASSWORD(‘123456‘);
设置远程登陆mysql数据库的密码
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
退出,到此mysql编译安装结束
本文参考链接:http://blog.csdn.net/wendi_0506/article/details/39478369
本文出自 “我的小天堂” 博客,请务必保留此出处http://9918511.blog.51cto.com/9908511/1639364
原文:http://9918511.blog.51cto.com/9908511/1639364