yum -y install gcc* libxml2-dev curl screen libpng12-dev autoconf libpcre3-dev make bzip2 libevent-dev patch libjpeg62-dev libcurl4-openssl-dev libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz libaio bison* openssl* ncurses* c++
或者:
yum -y install dialog vim-enhanced vixie-cron gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc \
glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel \
libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel \
libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn \
libidn-devel openssl openssl-devel make c++
需要先安装cmake
http://www.cmake.org/cmake/resources/software.html
下载源码包,安装cmake方法和其他的安装相同,解压,配置,编译,安装
$ ./bootstrap; make; make install
1.添加用户组
groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql
2.编译安装
#cd /usr/local/
tar -zxvf mysql-5.5.36.tar.gz
mv mysql-5.5.36 mysql
cd mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
-DINSTALL_DATADIR=/data/mysqldb\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DEXTRA_CHARSETS=all\
-DWITH_SSL=system\
-DENABLED_LOCAL_INFILE=1\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_ARCHIVE_STORAGE_ENGINE=1\
-DWITH_PARTITION_STORAGE_ENGINE=1\
-DENABLED_LOCAL_INFILE=1\
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock\
-DSYSCONFDIR=/etc\
-DMYSQL_TCP_PORT=3306\
-DMYSQL_USER=mysql
/*
//下面是开启额外数据库引擎的配置,要开启必须如下手动配置
//MyISAM, MERGE, MEMORY, and CSV引擎是默认安装的
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
*/
以上是5.5
以下是5.6
----------------------------------------
------------------------------
支持所有的字符集编码所有编码
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_ZLIB:STRING=bundled -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1 -DWITH_SSL:STRING=bundled
------------------------------
make
make install
cd /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chmod +x scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb
----------------------------------------------------------------------------------------------
cp support-files/my-medium.cnf /etc/my.cnf ( mysql 5.5)
cp support-files/my-default.cnf /etc/my.cnf (mysql 5.6)
---------------------------------------------------------
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mysqldb
vim /etc/my.cnf
/*
basedir=/usr/local/mysql
datadir=/data/myslqdb
*/
cp /usr/local/mysql/bin/my_print_defaults /usr/bin/
chown -R mysql:mysql /usr/local/mysql
bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
vim /etc/init.d/mysql
/*
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
*/
chkconfig --add mysql
chkconfig --level 2345 mysql on
service mysql start
4.安装后检测并修改root密码
/usr/local/mysql/bin/mysqladmin version
/usr/local/mysql/bin/mysqladmin ping
ln -s /usr/local/mysql/bin/mysql /usr/bin/
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/
去除一些用户/*根据实际情况使用*/
use mysql;
select user,host from user;
delete from user where user <> 'root';
delete from user where host <> 'localhost';
update user set host ='%' where user ='root';
select user,host from user;
设置root密码
mysqladmin -u root password "123!@#"
use mysql;
update user set password=password("123!@#") where user="root";
flush privileges;