《Mysql實例分享CentOS下MySQL最新版本5.6.13源碼安裝過程》要點:
本文介紹了Mysql實例分享CentOS下MySQL最新版本5.6.13源碼安裝過程,希望對您有用。如果有疑問,可以聯系我們。
2個月前公司給DBA的測試服務器被收回去了,一直跟開發用一組DB,有些需要測試的小功能,需要不斷重啟db,為了不影響開發同事,自己又申請了一個虛擬機,準備安裝最新的5.6.13版本的MySQL社區版. 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/MYSQL數據庫
2 安裝cmake軟件包
yum install cmakeMYSQL數據庫
3 create account of mysql
groupadd mysql??????????
useradd -g mysql mysql??????????
autoreconf --force --install
libtoolize --automake --force
automake --force --add-missingMYSQL數據庫
4? complie the sources
mkdir -p /data/mbdata
tar -xvf mysql-5.6.13.tar.gz MYSQL數據庫
5 cmake MYSQL數據庫
?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_ciMYSQL數據庫
[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!MYSQL數據庫
real??? 0m0.017s
user??? 0m0.006s
sys???? 0m0.005sMYSQL數據庫
6 上一步cmake報錯了,google得知需要重新yum make下 MYSQL數據庫
yum install make
okMYSQL數據庫
再繼續去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)MYSQL數據庫
這個錯誤很詭異,google上面有很多,但是每種情況都不同,我只好一個個去try了MYSQL數據庫
-- Configuring incomplete, errors occurred!MYSQL數據庫
real??? 0m0.122s
user??? 0m0.067s
sys???? 0m0.048s
[root@472322 mysql-5.6.13]# MYSQL數據庫
報錯如下: 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++ MYSQL數據庫
Ok,yum成功MYSQL數據庫
7? 繼續cmake MYSQL數據庫
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 MYSQL數據庫
[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!MYSQL數據庫
real??? 0m0.510s
user??? 0m0.275s
sys???? 0m0.112s MYSQL數據庫
第二次嘗試,有人說需要安裝至少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 MYSQL數據庫
然后再cmake,還是報原來的錯誤?? MYSQL數據庫
最后決定用土辦法了,刪除所有的已經安裝過的,重新再來做一遍吧. MYSQL數據庫
[解決辦法]:刪除原來的mysql-5.6.13目錄,重新解壓縮tar.gz包MYSQL數據庫
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.13MYSQL數據庫
real??? 0m23.413s
user??? 0m13.815s
sys???? 0m7.419sMYSQL數據庫
OK,成功了,對linux底層不太熟悉,難道是因為前面沒有事先安裝好各種包而cmake出來錯誤的東西導致后面繼續cmake就一直報錯嗎? 是否是需要準備好各種lib包然后才能yum install cmake呢?然后再安裝mysql才能不報錯呢? MYSQL數據庫
8 build the db directy
time make
time make installMYSQL數據庫
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
OKMYSQL數據庫
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
OKMYSQL數據庫
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your systemMYSQL數據庫
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:MYSQL數據庫
? /usr/local/mysql56/bin/mysqladmin -u root password 'new-password'
? /usr/local/mysql56/bin/mysqladmin -u root -h 472322.ea.com password 'new-password'MYSQL數據庫
Alternatively you can run:MYSQL數據庫
? /usr/local/mysql56/bin/mysql_secure_installationMYSQL數據庫
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.MYSQL數據庫
See the manual for more instructions.MYSQL數據庫
You can start the MySQL daemon with:MYSQL數據庫
? cd . ; /usr/local/mysql56/bin/mysqld_safe &MYSQL數據庫
You can test the MySQL daemon with mysql-test-run.plMYSQL數據庫
? cd mysql-test ; perl mysql-test-run.plMYSQL數據庫
Please report any problems with the ./bin/mysqlbug script!MYSQL數據庫
The latest information about MySQL is available on the web atMYSQL數據庫
? http://www.mysql.comMYSQL數據庫
Support MySQL by buying support/licenses at http://shop.mysql.comMYSQL數據庫
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 settingsMYSQL數據庫
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 serverMYSQL數據庫
感到信息有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
OKMYSQL數據庫
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
OKMYSQL數據庫
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your systemMYSQL數據庫
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:MYSQL數據庫
? /usr/local/mysql56/bin/mysqladmin -u root password 'new-password'
? /usr/local/mysql56/bin/mysqladmin -u root -h 472322.ea.com password 'new-password'MYSQL數據庫
Alternatively you can run:MYSQL數據庫
? /usr/local/mysql56/bin/mysql_secure_installationMYSQL數據庫
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.MYSQL數據庫
See the manual for more instructions.MYSQL數據庫
You can start the MySQL daemon with:MYSQL數據庫
? cd . ; /usr/local/mysql56/bin/mysqld_safe &MYSQL數據庫
You can test the MySQL daemon with mysql-test-run.plMYSQL數據庫
? cd mysql-test ; perl mysql-test-run.plMYSQL數據庫
Please report any problems with the ./bin/mysqlbug script!MYSQL數據庫
The latest information about MySQL is available on the web atMYSQL數據庫
? http://www.mysql.comMYSQL數據庫
Support MySQL by buying support/licenses at http://shop.mysql.comMYSQL數據庫
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.MYSQL數據庫
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 serverMYSQL數據庫
10 copy start command MYSQL數據庫
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/profileMYSQL數據庫
11 add command to system parameter
cd /data56
chkconfig --add mysqld56MYSQL數據庫
12? start service & check & login
service mysqld56 startMYSQL數據庫
[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 distributionMYSQL數據庫
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.MYSQL數據庫
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.MYSQL數據庫
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MYSQL數據庫
mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
| test?????????????? |
+--------------------+
4 rows in set (0.00 sec)MYSQL數據庫
mysql>? MYSQL數據庫
總結疑問:對linux底層不太熟悉,難道是因為前面沒有事先安裝好各種包而cmake出來錯誤的東西導致后面繼續cmake就一直報錯嗎? 是否是需要準備好各種lib包然后才能yum install cmake呢?然后再安裝mysql才能不報錯呢? MYSQL數據庫
歡迎熟悉linux底層的朋友或者有過這方面的經歷的朋友給出寶貴的意見.MYSQL數據庫