CentOS5.5 下编译 mysql 5.5.10

安装开发工具
yum groupinstall “Development Tools”

安装依赖包
yum install ncurses-devel

安装 cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4

./configure

make
make install

下载mysql

wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.5.10.tar.gz

tar zvxf mysql-5.5.10.tar.gz

cd mysql-5.5.10

编译

cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1\
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0

make

make install

添加用户和组

useradd -M -r –shell /sbin/nologin –home-dir / mysql

添加执行程序的软链接,这只是为了方便,喜欢用完整路径的可以不做,这一步也可以不用

sudo ln -s /usr/local/mysql/bin/mysql /usr/bin/
sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/
sudo ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/
sudo ln -s /usr/local/mysql/bin/mysql_conf /usr/bin/

更改当前目录,注意:以下都是在/usr/local/mysql目录下操作

cd /usr/local/mysql

修改权限

chown -R mysql:mysql /usr/local/mysql

复制配置文件
cp support-files/my-medium.cnf /etc/my.cnf

复制启动脚本
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld

初始化数据库
./scripts/mysql_install_db –user=mysql

启动数据库
/etc/rc.d/init.d/mysqld start

按照这个操作应该没有错误

添加服务自动启动

chkconfig –add mysqld

停止mysql

/etc/rc.d/init.d/mysqld stop

启动mysql服务

service mysqld start

添加Mysql用户密码,确保Mysql Server已启动
mysql -u root
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘新密码’);

\q
或者

mysqladmin -u root password ‘新密码’

备注:写这篇文档时候喝了点小酒,可能有个别的小错误

注意:chkconfig在/sbin目录下,默认这个目录不在环境变量$PATH中,修改/etc/profile文件

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC这个后面添加以下一行:

export PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH

然后重启或者注销

3 thoughts on “CentOS5.5 下编译 mysql 5.5.10

  1. CMake Error: The source directory “/root/Mysoft/mysql-5.5.11-linux2.6-i686” does not appear to contain CMakeLists.txt.
    Specify –help for usage, or press the help button on the CMake GUI.

Comments are closed.