使用cmake安装mysql5.5.13

时间:2023-11-25 19:32:26

MySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具。
因此,我们首先要在系统中源码编译安装cmake工具。

安装cmake :

tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure --prefix=/usr/local/cmake
make && make install

  

安装mysql5.5.13

groupadd mysql              //所以在这里我们要建一个msyql的用户和组
useradd -g mysql mysql -s /usr/sbin/nologin
mkdir /usr/local/mysql //创建目录
mkdir /usr/local/mysql/data

  

进入mysql-5.5.13的解压目录:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql && make && make install

  

进入mysql的安装目录/usr/local/mysql下:

[root@localhost scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql  //初始化mysql数据库
[root@localhost scripts]#cp /use/local/mysql/support-files/my-medium.cnf /usr/local/mysql/my.cnf //copy配置文件
[root@localhost scripts]#chown -R mysql:mysql /usr/local/mysql //更改权限

  

vim /usr/local/mysql/my.cnf  //加上以下内容

[mysqld]
port = 3306
socket = /tmp/mysql.sock
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log-error = /home/mysql/log
pid-file = /home/mysql/mysql.pid
tmpdir = /tmp

启动mysql

[root@localhost bin]#./mysqld_safe --user=mysql & 或使用下列命令把mysql添加为系统服务。
[root@localhost bin]#cd /usr/local/mysql/support-files/
[root@localhost support-files]#cp ./mysql.server /etc/init.d/mysqld
[root@localhost support-files]#/etc/init.d/mysqld start

  

高版本的mysql可以兼容低版本的。