http://www.linuxidc.com/Linux/2012-02/54342.htm
mysql 最新的版本都需要cmake编译安装,估计以后的版本也会采用这种方式,所以特地记录一下安装步骤及过程,以供参考。
注意:此安装是默认RedHat下已经安装了最新工具包,比如GNU make, GCC, Perl, libncurses5-dev,如果在编译安装过程中发现有缺失的工具包,先yum install 单独下载安装再继续即可。
相关教程:
RedHat Linux 2.6.18下安装MySQL 5.1.7及Navicat 8 见 http://www.linuxidc.com/Linux/2011-06/37081.htmredhat9下安装mysql-4.0.26记 见 http://www.linuxidc.com/Linux/2008-01/10276.htm
RedHat下MySQL 5.6 安装、维护 见 http://www.linuxidc.com/Linux/2011-10/44882.htm
一. linux用 wget 下载需要的软件,保存到目录 /usr/local/src 下
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.gz
wget 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.tar.gz
./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=/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_MEMORY_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/mysql/data \
-DMYSQL_USER=mysql
-- 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 /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18
mkdir -p /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql/data
ln -s /usr/local/mysql/data /home/mysql/data
mkdir -p /var/mysql/log/
chown -R mysql:mysql /var/mysql/
cd support-files/
cp my-large.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
四. 配置启动MySQL 5.5.20
1. 若有需要请先修改 mysql 的配置 my.cnf
vi /etc/my.cnf
[mysqld] 下添加
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
2.my.cnfmysql 初始化安装
/usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data \
--user=mysql
3. 将 mysql 加入开机启动
chmod +x /etc/init.d/mysqld
vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:)
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
chkconfig --add mysqld
chkconfig --level 345 mysqld on
4. 启动 mysql
service mysqld start
5. 配置root帐号
/usr/local/mysql/bin/mysqladmin -uroot password zdsoft
/usr/local/mysql/bin/mysql -uroot -p
mysql>use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO taxioncall@'%' IDENTIFIED BY 'zdsoft' with GRANT OPTION;
mysql>update user set password=password('zdsoft'); --所有用户都密码更新
mysql>FLUSH PRIVILEGES;
mysql>quit;