wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.5/mysql-5.5.20.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gzwget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
二.安装cmake
cd /usr/local/src
tar zxvf cmake-2.8.7.tar.gz
cd cmake-2.8.7
./bootstrap
gmake
gmake install
cd ../
tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure
make
make install
cd ../
三.编译安装MySQL 5.5.20
groupadd -g 1000 mysql
useradd -u 1000 -g mysql mysql
tar xvf mysql-5.5.20.tar.gz
cd mysql-5.5.20/
/usr/local/bin/cmake-DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_UNIX_ADDR=/opt/mysql/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_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/opt/mysql/data \
-DSYSCONFDIR=/opt/mysql \
-DMYSQL_TCP_PORT=3306
-- Could NOT find Curses (missing:CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Pleaseinstall appropriate package,
removeCMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name islibncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:117 (FIND_CURSES)
cmake/readline.cmake:213(MYSQL_USE_BUNDLED_READLINE)
CMakeLists.txt:250 (MYSQL_CHECK_READLINE)
yum install ncurses-devel
rm CMakeCache.txt
--这里重新开始做上面的cmake操作即可
make
make install
chmod +w /opt/mysql
chown -R mysql:mysql /opt/mysql
ln -s /opt/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
mkdir -p /opt/mysql/data
chown -R mysql:mysql /opt/mysql/data
mkdir -p /opt/mysql/log
chown -R mysql:mysql /opt/mysql/log
cd support-files/
如果你的内存≤64m,复制my-small.cnf;内存64-128m,复制my-medium.cnf;内存128-512m,复制my-large.cnf;内存1-2g,复制my-huge.cnf;内存4g以上,复制my-innodb-heavy-4G.cnfcp my-large.cnf /etc/my.cnf
[mysqld] 下添加
basedir = /opt/mysql
datadir = /opt/mysql/data
2.my.cnfmysql初始化安装
chmod +x/opt/mysql/scripts/mysql_install_db
/opt/mysql/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--basedir=/opt/mysql \
--datadir=/opt/mysql/data \
--user=mysql
3.将mysql加入开机启动
chmod +x /etc/init.d/mysqld
vi /etc/init.d/mysqld(编辑此文件,查找并修改以下变量内容:)
basedir=/opt/mysql
datadir=/opt/mysql/data
chkconfig --add mysqld
chkconfig --level 345 mysqld on
4.启动mysql
service mysqld start
5.配置访问帐号root
/opt/mysql/bin/mysqladmin -uroot password zdsoft
/opt/mysql/bin/mysql -uroot -p
mysql>use mysql;
mysql>GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'zdsoft' with GRANT OPTION;
mysql>update user set password=password('zdsoft'); --所有用户都密码更新
mysql>FLUSH PRIVILEGES;
mysql>quit;