yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib fiex libxml ncurses-devel libmcrypt libtool-ltdl-devel cmake bison git openssl-devel libtirpc-devel
groupadd mysql
useradd -g mysql mysql
mkdir -p /data/mysql
chown mysql.mysql -R /data/mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_TCP_PORT=53306 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
(编译出错 rm -rf CMakeCache.txt)
make && make install
安装完后要进行数据库的初始化
cd /usr/local/mysql
bin/mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql --socket=/tmp/mysql.sock
编辑配置文件my.cmf
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --add /etc/init.d/mysql
chkconfig mysql --level 235 on
echo "export PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
source /etc/profile
设定root密码
service mysql start
mysqladmin -u root password '123456'
set password for 'root'@'localhost'=password('123456');
use mysql;
show tables;
select host,user from user;
GRANT ALL PRIVILEGES ON . to 'test'@'%' identified by '123456' WITH GRANT OPTION;
flush privileges;
忘记root密码
UPDATE user SET authentication_string=password('123456') where USER='root';
update user set password=password('123456') where user='root';