CentOS下用源码安装mysql

记录如下:

1. install CMake and bison.

2. prepare the user/group, and folder.
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

mkdir -p /var/mysql/
mkdir -p /var/mysql/data/
mkdir -p /var/mysql/log/
chown -R mysql:mysql /var/mysql/

3. untar the source code, and build
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=/var/mysql/data

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


4. Copy the config file. -- change if you want.
cd support-files/
cp my-large.cnf /var/mysql/my.cnf
cp mysql.server /etc/init.d/mysqld

5. init install
/usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/var/mysql/my.cnf \
--basedir=/usr/local/mysql \
--datadir=/var/mysql/data \
--user=mysql

6. start mysql.
chmod +x /etc/init.d/mysqld
service mysqld start

7. Add mysql into PATH.
export PATH=/usr/local/mysql/bin:$PATH

8. test the connect.

 

 

参考URL如下:

http://hi.baidu.com/mucunzhishu/item/aa78b3eaa9f518ffe0a5d487
centos下 MySQL 5.5.23 CMake 安装笔记

http://turbolinux.org/2011/05/install-mysql-5-5-on-centos-using-cmake/
Install Mysql 5.5 on CentOS using CMake

http://www.linuxidc.com/Linux/2011-06/37059.htm
CentOS 5.6下使用cmake编译MySQL 5.5.13源码和安装笔录

 

你可能感兴趣的:(CentOS下用源码安装mysql)