教程集 www.jiaochengji.com
教程集 >  数据库  >  mysql  >  正文 centos下mysql 5.6.13源码安装方法

centos下mysql 5.6.13源码安装方法

发布时间:2016-04-25   编辑:jiaochengji.com
本文介绍了centos下安装mysql最新版本5.6.13的方法,mysql数据库的编译安装方法,有需要的朋友参考下。

2个月前公司给dba的测试服务器被收回去了,一直跟开发用一组db,有些需要测试的小功能,需要不断重启db。
申请了一个虚拟机,准备安装最新的5.6.13版本的mysql社区版。
1 download the tar.gz
 

复制代码 代码示例:
wget http://dev.mysql.com/get/downloads/mysql-5.6/mysql-5.6.13.tar.gz/from/http://cdn.mysql.com/

2 安装cmake软件包
 

复制代码 代码示例:
yum install cmake
 

3 create account of mysql
 

复制代码 代码示例:
groupadd mysql          
useradd -g mysql mysql          
autoreconf --force --install
libtoolize --automake --force
automake --force --add-missing
 

4  complie the sources
 

复制代码 代码示例:
mkdir -p /data/mbdata
tar -xvf mysql-5.6.13.tar.gz

5 cmake
 time cmake . -dcmake_install_prefix=/usr/local/mysql56 -dmysql_datadir=/data56 -dwith_innobase_storage_engine=1 -dmysql_unix_addr==/data56/mysql.sock -dmysql_user=mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci
[root@472322 mysql-5.6.13]# time cmake . -dcmake_install_prefix=/usr/local/mysql56 -dmysql_datadir=/data56 -dwith_innobase_storage_engine=1 -dmysql_unix_addr==/data56/mysql.sock -dmysql_user=mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci
-- running cmake version 2.6.4
cmake error: cmake was unable to find a build program corresponding to "unix makefiles".  cmake_make_program is not set.  you probably need to select a different build tool.
cmake error: error required internal cmake variable not set, cmake may be not be built correctly.
missing variable is:
cmake_c_compiler_env_var
cmake error: error required internal cmake variable not set, cmake may be not be built correctly.
missing variable is:
cmake_c_compiler
cmake error: could not find cmake module file:/root/mysql-5.6.13/cmakefiles/cmakeccompiler.cmake
cmake error: error required internal cmake variable not set, cmake may be not be built correctly.
missing variable is:
cmake_cxx_compiler_env_var
cmake error: error required internal cmake variable not set, cmake may be not be built correctly.
missing variable is:
cmake_cxx_compiler
cmake error: could not find cmake module file:/root/mysql-5.6.13/cmakefiles/cmakecxxcompiler.cmake
cmake error: cmake_c_compiler not set, after enablelanguage
cmake error: cmake_cxx_compiler not set, after enablelanguage
-- configuring incomplete, errors occurred!
real    0m0.017s
user    0m0.006s
sys     0m0.005s

6 上一步cmake报错了,google得知需要重新yum make下
yum install make
ok
再继续去cmake
 

复制代码 代码示例:
[root@472322 mysql-5.6.13]# time cmake . -dcmake_install_prefix=/usr/local/mysql56 -dmysql_datadir=/data56 -dwith_innobase_storage_engine=1 -dmysql_unix_addr==/data56/mysql.sock -dmysql_user=mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci
-- running cmake version 2.6.4
-- the c compiler identification is unknown
-- the cxx compiler identification is unknown
cmake error: your c compiler: "cmake_c_compiler-notfound" was not found.   please set cmake_c_compiler to a valid compiler path or name.
cmake error: your cxx compiler: "cmake_cxx_compiler-notfound" was not found.   please set cmake_cxx_compiler to a valid compiler path or name.
-- mysql 5.6.13
-- packaging as: mysql-5.6.13-linux-x86_64
-- could not find threads  (missing:  threads_found)
-- could not find threads  (missing:  threads_found)
-- check if the system is big endian
-- searching 16 bit integer
cmake error at /usr/share/cmake/modules/testbigendian.cmake:31 (message):
  no suitable type found
call stack (most recent call first):
  configure.cmake:621 (test_big_endian)
  cmakelists.txt:314 (include)
 

这个错误很诡异,google上面有很多,但是每种情况都不同,我只好一个个去try了
-- configuring incomplete, errors occurred!
real    0m0.122s
user    0m0.067s
sys     0m0.048s
[root@472322 mysql-5.6.13]#
报错如下: cmake error: your c compiler: "cmake_c_compiler-notfound" was not found.
 没有安装 gcc 和 gcc-c++,执行cmake报如上错误:
 第一次尝试,执行
 

复制代码 代码示例:
yum install -y gcc
yum install -y gcc-c++


ok,yum成功

7  继续cmake
time cmake . -dcmake_install_prefix=/usr/local/mysql56 -dmysql_datadir=/data56 -dwith_innobase_storage_engine=1 -dmysql_unix_addr==/data56/mysql.sock -dmysql_user=mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci
 

复制代码 代码示例:
[root@472322 mysql-5.6.13]#
time cmake . -dcmake_install_prefix=/usr/local/mysql56 -dmysql_datadir=/data56 -dwith_innobase_storage_engine=1 -dmysql_unix_addr==/data56/mysql.sock -dmysql_user=mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci
-- running cmake version 2.6.4
-- the c compiler identification is gnu
-- the cxx compiler identification is gnu
-- check for working c compiler: /usr/bin/gcc
-- check for working c compiler: /usr/bin/gcc -- works
-- detecting c compiler abi info
-- detecting c compiler abi info - done
-- check for working cxx compiler: /usr/bin/c++
-- check for working cxx compiler: /usr/bin/c++ -- works
-- detecting cxx compiler abi info
-- detecting cxx compiler abi info - done
-- mysql 5.6.13
-- packaging as: mysql-5.6.13-linux-x86_64
-- could not find threads  (missing:  threads_found)
-- could not find threads  (missing:  threads_found)
-- check if the system is big endian
-- searching 16 bit integer
cmake error at /usr/share/cmake/modules/testbigendian.cmake:31 (message):
  no suitable type found
call stack (most recent call first):
  configure.cmake:621 (test_big_endian)
  cmakelists.txt:314 (include)
-- configuring incomplete, errors occurred!
real    0m0.510s
user    0m0.275s
sys     0m0.112s
 

第二次尝试,有人说需要安装至少5种包
 

复制代码 代码示例:
[root@472322 mysql-5.6.13]#
yum install gcc gcc-c++
    yum install -y ncurses-devel.x86_64
    yum install -y cmake.x86_64
    yum install -y libaio.x86_64
    yum install -y bison.x86_64
yum install -y gcc-c++.x86_64
 

然后再cmake,还是报原来的错误 
最后决定用土办法了,删除所有的已经安装过的,重新再来做一遍吧。
[解决办法]:删除原来的mysql-5.6.13目录,重新解压缩tar.gz包
 

复制代码 代码示例:
rm -rf /root/mysql-5.6.13
cd /root/
tar -xvf mysql-5.6.13.tar.gz
cd /root/mysql-5.6.13
time cmake . -dcmake_install_prefix=/usr/local/mysql56 -dmysql_datadir=/data56 -dwith_innobase_storage_engine=1 -dmysql_unix_addr==/data56/mysql.sock -dmysql_user=mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci
........
-- looking for asprintf
-- looking for asprintf - found
-- check size of pthread_t
-- check size of pthread_t - done
-- using cmake version 2.6.4
-- not building ndb
-- performing test have_peercred
-- performing test have_peercred - success
-- library mysqlclient depends on oslibs -lpthread;m;rt;dl
-- googlemock was not found. gtest-based unit tests will be disabled. you can run cmake . -denable_downloads=1 to automatically download and build required components from source.
-- if you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
-- library mysqlserver depends on oslibs -lpthread;m;rt;crypt;dl
-- configuring done
-- generating done
-- build files have been written to: /root/mysql-5.6.13
real    0m23.413s
user    0m13.815s
sys     0m7.419s
 

ok,成功了,对linux底层不太熟悉,难道是因为前面没有事先安装好各种包而cmake出来错误的东西导致后面继续cmake就一直报错吗? 是否是需要准备好各种lib包然后才能yum install cmake呢?然后再安装mysql才能不报错呢?

8 build the db directy
 

复制代码 代码示例:
time make
time make install

9 init db
 

复制代码 代码示例:
ll /usr/local/mysql56/
cd /usr/local/mysql56/
chown -r mysql .
chgrp -r mysql .
cp support-files/my-default.cnf /etc/my56.cnf
scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql56 --datadir=/data56 --defaults-file=/etc/my56.cnf
[root@472322 mysql56]# scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql56 --datadir=/data56 --defaults-file=/etc/my56.cnf
installing mysql system tables...2013-08-22 05:06:03 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-08-22 05:06:03 19416 [note] innodb: the innodb memory heap is disabled
2013-08-22 05:06:03 19416 [note] innodb: mutexes and rw_locks use gcc atomic builtins
2013-08-22 05:06:03 19416 [note] innodb: compressed tables use zlib 1.2.3
2013-08-22 05:06:03 19416 [note] innodb: using cpu crc32 instructions
2013-08-22 05:06:03 19416 [note] innodb: initializing buffer pool, size = 128.0m
2013-08-22 05:06:03 19416 [note] innodb: completed initialization of buffer pool
2013-08-22 05:06:03 19416 [note] innodb: the first specified data file ./ibdata1 did not exist: a new database to be created!
2013-08-22 05:06:03 19416 [note] innodb: setting file ./ibdata1 size to 12 mb
2013-08-22 05:06:03 19416 [note] innodb: database physically writes the file full: wait...
2013-08-22 05:06:03 19416 [note] innodb: setting log file ./ib_logfile101 size to 48 mb
2013-08-22 05:06:03 19416 [note] innodb: setting log file ./ib_logfile1 size to 48 mb
2013-08-22 05:06:03 19416 [note] innodb: renaming log file ./ib_logfile101 to ./ib_logfile0
2013-08-22 05:06:03 19416 [warning] innodb: new log files created, lsn=45781
2013-08-22 05:06:03 19416 [note] innodb: doublewrite buffer not found: creating new
2013-08-22 05:06:03 19416 [note] innodb: doublewrite buffer created
2013-08-22 05:06:03 19416 [note] innodb: 128 rollback segment(s) are active.
2013-08-22 05:06:03 19416 [warning] innodb: creating foreign key constraint system tables.
2013-08-22 05:06:03 19416 [note] innodb: foreign key constraint system tables created
2013-08-22 05:06:03 19416 [note] innodb: creating tablespace and datafile system tables.
2013-08-22 05:06:03 19416 [note] innodb: tablespace and datafile system tables created.
2013-08-22 05:06:03 19416 [note] innodb: waiting for purge to start
2013-08-22 05:06:03 19416 [note] innodb: 5.6.13 started; log sequence number 0
2013-08-22 05:06:04 19416 [note] binlog end
2013-08-22 05:06:04 19416 [note] innodb: fts optimize thread exiting.
2013-08-22 05:06:04 19416 [note] innodb: starting shutdown...
2013-08-22 05:06:05 19416 [note] innodb: shutdown completed; log sequence number 1625977
ok
filling help tables...2013-08-22 05:06:05 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-08-22 05:06:05 19439 [note] innodb: the innodb memory heap is disabled
2013-08-22 05:06:05 19439 [note] innodb: mutexes and rw_locks use gcc atomic builtins
2013-08-22 05:06:05 19439 [note] innodb: compressed tables use zlib 1.2.3
2013-08-22 05:06:05 19439 [note] innodb: using cpu crc32 instructions
2013-08-22 05:06:05 19439 [note] innodb: initializing buffer pool, size = 128.0m
2013-08-22 05:06:05 19439 [note] innodb: completed initialization of buffer pool
2013-08-22 05:06:05 19439 [note] innodb: highest supported file format is barracuda.
2013-08-22 05:06:05 19439 [note] innodb: 128 rollback segment(s) are active.
2013-08-22 05:06:05 19439 [note] innodb: waiting for purge to start
2013-08-22 05:06:05 19439 [note] innodb: 5.6.13 started; log sequence number 1625977
2013-08-22 05:06:05 19439 [note] binlog end
2013-08-22 05:06:05 19439 [note] innodb: fts optimize thread exiting.
2013-08-22 05:06:05 19439 [note] innodb: starting shutdown...
2013-08-22 05:06:06 19439 [note] innodb: shutdown completed; log sequence number 1625987
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:
  /usr/local/mysql56/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql56/bin/mysqladmin -u root -h 472322.ea.com password 'new-password'
alternatively you can run:
  /usr/local/mysql56/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 . ; /usr/local/mysql56/bin/mysqld_safe &
you can test the mysql daemon with mysql-test-run.pl
  cd mysql-test ; perl mysql-test-run.pl
please report any problems with the ./bin/mysqlbug script!
the latest information about mysql is available on the web at
  http://www.mysql.com
support mysql by buying support/licenses at http://shop.mysql.com
new default config file was created as /usr/local/mysql56/my.cnf and
will be used by default by the server when you start it.
you may edit this file to change server settings
warning: default config file /etc/my.cnf exists on the system
this file will be read by default by the mysql server
if you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
感到信息有warning,那就重新再执行一遍,原来在做5.6.10安装测试的时候,init db不管第一次执行失败或者成功,都可以再执行第二遍的。
[root@472322 mysql56]#
[root@472322 mysql56]# ll etc/my56.cnf
ls: cannot access etc/my56.cnf: no such file or directory
[root@472322 mysql56]# ll /etc/my56.cnf
-rw-r--r-- 1 root root 1126 aug 22 05:05 /etc/my56.cnf
[root@472322 mysql56]# scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql56 --datadir=/data56 --defaults-file=/etc/my56.cnf
installing mysql system tables...2013-08-22 05:07:31 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-08-22 05:07:31 19481 [note] innodb: the innodb memory heap is disabled
2013-08-22 05:07:31 19481 [note] innodb: mutexes and rw_locks use gcc atomic builtins
2013-08-22 05:07:31 19481 [note] innodb: compressed tables use zlib 1.2.3
2013-08-22 05:07:31 19481 [note] innodb: using cpu crc32 instructions
2013-08-22 05:07:31 19481 [note] innodb: initializing buffer pool, size = 128.0m
2013-08-22 05:07:31 19481 [note] innodb: completed initialization of buffer pool
2013-08-22 05:07:31 19481 [note] innodb: highest supported file format is barracuda.
2013-08-22 05:07:31 19481 [note] innodb: 128 rollback segment(s) are active.
2013-08-22 05:07:31 19481 [note] innodb: waiting for purge to start
2013-08-22 05:07:31 19481 [note] innodb: 5.6.13 started; log sequence number 1625987
2013-08-22 05:07:31 19481 [note] binlog end
2013-08-22 05:07:31 19481 [note] innodb: fts optimize thread exiting.
2013-08-22 05:07:31 19481 [note] innodb: starting shutdown...
2013-08-22 05:07:32 19481 [note] innodb: shutdown completed; log sequence number 1625997
ok
filling help tables...2013-08-22 05:07:32 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-08-22 05:07:32 19505 [note] innodb: the innodb memory heap is disabled
2013-08-22 05:07:32 19505 [note] innodb: mutexes and rw_locks use gcc atomic builtins
2013-08-22 05:07:32 19505 [note] innodb: compressed tables use zlib 1.2.3
2013-08-22 05:07:32 19505 [note] innodb: using cpu crc32 instructions
2013-08-22 05:07:32 19505 [note] innodb: initializing buffer pool, size = 128.0m
2013-08-22 05:07:32 19505 [note] innodb: completed initialization of buffer pool
2013-08-22 05:07:32 19505 [note] innodb: highest supported file format is barracuda.
2013-08-22 05:07:32 19505 [note] innodb: 128 rollback segment(s) are active.
2013-08-22 05:07:32 19505 [note] innodb: waiting for purge to start
2013-08-22 05:07:32 19505 [note] innodb: 5.6.13 started; log sequence number 1625997
2013-08-22 05:07:32 19505 [note] binlog end
2013-08-22 05:07:32 19505 [note] innodb: fts optimize thread exiting.
2013-08-22 05:07:32 19505 [note] innodb: starting shutdown...
2013-08-22 05:07:34 19505 [note] innodb: shutdown completed; log sequence number 1626007
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:
  /usr/local/mysql56/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql56/bin/mysqladmin -u root -h 472322.ea.com password 'new-password'
alternatively you can run:
  /usr/local/mysql56/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 . ; /usr/local/mysql56/bin/mysqld_safe &
you can test the mysql daemon with mysql-test-run.pl
  cd mysql-test ; perl mysql-test-run.pl
please report any problems with the ./bin/mysqlbug script!
the latest information about mysql is available on the web at
  http://www.mysql.com
support mysql by buying support/licenses at http://shop.mysql.com
warning: found existing config file /usr/local/mysql56/my.cnf on the system.
because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
the new default config file was created as /usr/local/mysql56/my-new.cnf,
please compare it with your file and take the changes you need.
warning: default config file /etc/my.cnf exists on the system
this file will be read by default by the mysql server
if you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
10 copy start command
cp support-files/mysql.server /etc/init.d/mysqld56
chmod 700 /etc/init.d/mysqld56
echo "export path=$path:/usr/local/mysql56/bin">>/etc/profile
source /etc/profile
11 add command to system parameter
cd /data56
chkconfig --add mysqld56
12  start service & check & login
service mysqld56 start
[root@472322 data56]# service mysqld56 start
starting mysql. success!
[root@472322 data56]# mysql
welcome to the mysql monitor.  commands end with ; or \g.
your mysql connection id is 1
server version: 5.6.13 source distribution
copyright (c) 2000, 2013, oracle and/or its affiliates. all rights reserved.
oracle is a registered trademark of oracle corporation and/or its
affiliates. other names may be trademarks of their respective
owners.
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)
mysql>
 

总结疑问:对linux底层不太熟悉,难道是因为前面没有事先安装好各种包而cmake出来错误的东西导致后面继续cmake就一直报错吗?
是否是需要准备好各种lib包然后才能yum install cmake呢?
然后再安装mysql才能不报错呢?

CentOS 6.3下源码编译安装MySQL 5.6
CentOS 6.5编译安装Percona 5.6.15(步骤)
centos6.4编译安装mysql5.5及Sphinx引擎的方法详解
mysql编译安装及多实例安装的方法分享
fedroa中编译安装mysql5.5的实例参考

您可能感兴趣的文章:
MySQL-5.6.13 zip解压版的安装与配置教程
centos下mysql 5.6.13源码安装方法
CentOS 5.5使用yum安装LAMP(php环境)步骤分享
yum方式安装MySQL并设置密码
CentOS 6.3下源码编译安装MySQL 5.6
centos源码安装mysql-5.1.53的实例详解
Centos安装libxml2 'bin/rm: cannot remove libtoolT'...的解决方法
centos创建Mysql用户组的方法
学习centos安装php的mysql扩展
在CentOS-6.3中安装与配置Mysql-5.5.29

关键词: mysql安装  编译安装  编译安装mysql   
[关闭]
~ ~