使用cmake编译安装MySQL 5.5

首先将cmake-2.8.8.tar.gz、MySQL-5.5.32.tar.gz源码包上传至服务器。

解压并安装cmake

[root@localhost ~]# tar -zxvf cmake-2.8.8.tar.gz
[root@localhost ~]# cd cmake-2.8.8
[root@localhost cmake-2.8.8]# ./configure
......
-- Configuring done
-- Generating done
-- Build files have been written to: /root/cmake-2.8.8
---------------------------------------------
CMake has bootstrapped.  Now run gmake.

确保cmake没有错误发生

[root@localhost cmake-2.8.8]# echo $?
0

下面运行gmake命令
[root@localhost cmake-2.8.8]# gmake
[root@localhost cmake-2.8.8]# gmake install

3. 安装MySQL依赖表ncurses-devel

[root@localhost cmake-2.8.8]# yum install ncurses-devel -y

4. 创建mysql用户

[root@localhost cmake-2.8.8]# groupadd mysql
       
[root@localhost cmake-2.8.8]# useradd mysql -s /sbin/nologin -M -g mysql

5. 解压编译MySQL

[root@localhost ~]# cd ..
[root@localhost ~]# tar -zxvf mysql-5.5.32.tar.gz
[root@localhost ~]# cd mysql-5.5.32
[root@localhost mysql-5.5.32]#  cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
  -DMYSQL_DATADIR=/application/mysql-5.5.32/data \
  -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DWITH_EXTRA_CHARSETS=all \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
  -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
  -DWITH_SSL=yes  \
  -DENABLED_LOCAL_INFILE=1

[root@localhost mysql-5.5.32]# make && make install

为安装目录做一个link

[root@localhost mysql-5.5.32]# ln -s /application/mysql-5.5.32/ /application/mysql

将源代码目录中的配置文件copy到/etc目录下

[root@localhost mysql-5.5.32]# cp support-files/my-small.cnf /etc/my.cnf

6. 配置环境变量

1 [root@localhost mysql-5.5.32]# echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile

7. 授权mysql用户访问安装目录

[root@localhost mysql]# chown mysql.mysql -R /application/mysql

8. 初始化mysql数据库

[root@localhost scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
 
Alternatively you can run:
/application/mysql/bin/mysql_secure_installation
 
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
 
See the manual for more instructions.
 
You can start the MySQL daemon with:
cd /application/mysql ; /application/mysql/bin/mysqld_safe &
 
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql/mysql-test ; perl mysql-test-run.pl
 
Please report any problems with the /application/mysql/scripts/mysqlbug script!

9. 制作mysql启动脚本

[root@localhost mysql-5.5.32]# cp support-files/mysql.server /etc/init.d/mysqld

10 启动mysql

[root@localhost mysql-5.5.32]# /etc/init.d/mysqld start
Starting MySQL..       

基于Cmake编译安装MySQL 5.5       

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d5611adc80a170f76cd160a89335ae56.html