mysql原始碼安裝
1.原始碼包安裝,進入mysql.com網站,註冊一個oracle賬號,選擇5.6community Editon ,選擇source code ,下載類似:
mysql-xxx(version).tar.gz安裝包,大約30M。
2.上傳到Linux上,解壓命令 tar -xvzf mysql-5.6.32.tar.gz
3.進入到解壓後資料夾mysql-5.6.32,執行命令如下
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_PARTITION_STORAGE_ENGINE=1
第一次執行很有可能會報錯。在最後,cmake會提示你少了哪些安裝必須的包,比如我的系統提示我缺少了 ncurses-devel,執行
如下命令安裝 yum install ncurses-devel。刪除CMakeCache.txt檔案,重新執行cmake.
4.cmake 進行安裝前的驗證檢查,檢查最後透過會輸出如下資訊:
BLE_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=
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: HAVE_CONFIG_H
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql/mysql-5.6.32
5.安裝前cmake 成功執行後,執行make 命令,執行編譯,大概需要10分鐘。最後輸出如下資訊,表示built完成
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
6.接著執行命令:make install
-- Installing: /usr/local/mysql/sql-bench/innotest1a
-- Installing: /usr/local/mysql/sql-bench/innotest2
-- Installing: /usr/local/mysql/sql-bench/test-create
-- Installing: /usr/local/mysql/sql-bench/crash-me
-- Installing: /usr/local/mysql/sql-bench/innotest1
-- Installing: /usr/local/mysql/sql-bench/bench-init.pl
-- Installing: /usr/local/mysql/sql-bench/test-wisconsin
-- Installing: /usr/local/mysql/sql-bench/compare-results
-- Installing: /usr/local/mysql/sql-bench/copy-db
7.進入到指定的安裝目錄下/usr/local/mysql
[root@mysqlIns mysql-5.6.32]# cd /usr/local/mysql
[root@mysqlIns mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
8.進入data,你會發現只有test庫,沒有mysql庫,performance_schema庫。安裝mysql庫,初始化Innodb,執行命令:
./scripts/mysql_install_db --user=mysql
有錯誤報錯如下:
2016-08-26 11:42:00 22040 [ERROR] InnoDB: space header page consists of zero bytes in data file ./ibdata1
2016-08-26 11:42:00 22040 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2016-08-26 11:42:00 22040 [ERROR] Plugin 'InnoDB' init function returned error.
2016-08-26 11:42:00 22040 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-08-26 11:42:00 22040 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-08-26 11:42:00 22040 [ERROR] Aborting
解決辦法:把innodb在datadir目錄下的innodb系統檔案ibdata1,重做日誌檔案ib_logfile0-4,二進位制日誌binlog*刪除掉。
重新執行 ./scripts/mysql_install_db --user=mysql 問題解決。
9.最後啟動mysql,大功告成,啟動mysql
mysqld_safe --defaults-file=/usr/local/mysql/my.cnf
10.更改root密碼,按照提示
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h mysqlIns password 'new-password'
11.最後貼出我的my.cnf 檔案:
[mysqld]
innodb_data_file_path=ibdata1:12M:autoextend
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin=/usr/local/mysql/data/binlog
server_id=3
innodb_log_buffer_size=8388608
innodb_log_compressed_pages=ON
innodb_log_file_size=50331648
innodb_log_files_in_group=5
innodb_log_group_home_dir=./
innodb_data_file_path=ibdata1:12M:autoextend
slow_query_log=on
long_query_time=5
slow_query_log_file=/usr/local/mysql/data/mysqlIns-slow.log
sql_mode=oracle
character_set_server=utf8
collation_server=utf8_general_ci
[mysqld_safe]
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
mysql-xxx(version).tar.gz安裝包,大約30M。
2.上傳到Linux上,解壓命令 tar -xvzf mysql-5.6.32.tar.gz
3.進入到解壓後資料夾mysql-5.6.32,執行命令如下
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_PARTITION_STORAGE_ENGINE=1
第一次執行很有可能會報錯。在最後,cmake會提示你少了哪些安裝必須的包,比如我的系統提示我缺少了 ncurses-devel,執行
如下命令安裝 yum install ncurses-devel。刪除CMakeCache.txt檔案,重新執行cmake.
4.cmake 進行安裝前的驗證檢查,檢查最後透過會輸出如下資訊:
BLE_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=
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: HAVE_CONFIG_H
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql/mysql-5.6.32
5.安裝前cmake 成功執行後,執行make 命令,執行編譯,大概需要10分鐘。最後輸出如下資訊,表示built完成
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
6.接著執行命令:make install
-- Installing: /usr/local/mysql/sql-bench/innotest1a
-- Installing: /usr/local/mysql/sql-bench/innotest2
-- Installing: /usr/local/mysql/sql-bench/test-create
-- Installing: /usr/local/mysql/sql-bench/crash-me
-- Installing: /usr/local/mysql/sql-bench/innotest1
-- Installing: /usr/local/mysql/sql-bench/bench-init.pl
-- Installing: /usr/local/mysql/sql-bench/test-wisconsin
-- Installing: /usr/local/mysql/sql-bench/compare-results
-- Installing: /usr/local/mysql/sql-bench/copy-db
7.進入到指定的安裝目錄下/usr/local/mysql
[root@mysqlIns mysql-5.6.32]# cd /usr/local/mysql
[root@mysqlIns mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
8.進入data,你會發現只有test庫,沒有mysql庫,performance_schema庫。安裝mysql庫,初始化Innodb,執行命令:
./scripts/mysql_install_db --user=mysql
有錯誤報錯如下:
2016-08-26 11:42:00 22040 [ERROR] InnoDB: space header page consists of zero bytes in data file ./ibdata1
2016-08-26 11:42:00 22040 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2016-08-26 11:42:00 22040 [ERROR] Plugin 'InnoDB' init function returned error.
2016-08-26 11:42:00 22040 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-08-26 11:42:00 22040 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-08-26 11:42:00 22040 [ERROR] Aborting
解決辦法:把innodb在datadir目錄下的innodb系統檔案ibdata1,重做日誌檔案ib_logfile0-4,二進位制日誌binlog*刪除掉。
重新執行 ./scripts/mysql_install_db --user=mysql 問題解決。
9.最後啟動mysql,大功告成,啟動mysql
mysqld_safe --defaults-file=/usr/local/mysql/my.cnf
10.更改root密碼,按照提示
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h mysqlIns password 'new-password'
11.最後貼出我的my.cnf 檔案:
[mysqld]
innodb_data_file_path=ibdata1:12M:autoextend
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin=/usr/local/mysql/data/binlog
server_id=3
innodb_log_buffer_size=8388608
innodb_log_compressed_pages=ON
innodb_log_file_size=50331648
innodb_log_files_in_group=5
innodb_log_group_home_dir=./
innodb_data_file_path=ibdata1:12M:autoextend
slow_query_log=on
long_query_time=5
slow_query_log_file=/usr/local/mysql/data/mysqlIns-slow.log
sql_mode=oracle
character_set_server=utf8
collation_server=utf8_general_ci
[mysqld_safe]
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30393770/viewspace-2124065/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- MySQL 5.7.28 原始碼安裝MySql原始碼
- Mysql for Linux安裝配置之—— 原始碼安裝MySqlLinux原始碼
- mysql5.5.20原始碼安裝MySql原始碼
- 【轉】MySQL原始碼編譯安裝MySql原始碼編譯
- MySQL5.7.16原始碼編譯安裝MySql原始碼編譯
- 阿里雲mysql原始碼編譯安裝阿里MySql原始碼編譯
- Linux使用原始碼來安裝MySQL 5.7Linux原始碼MySql
- mysql之tar.gz原始碼安裝MySql原始碼
- mysql8.0原始碼一鍵安裝指令碼MySql原始碼指令碼
- MYSQL5.7.22 原始碼安裝 主從搭建MySql原始碼
- CentOS7.X原始碼安裝MySQL-5.7.18CentOS原始碼MySql
- Mysql5.6 for Centos6.5原始碼編譯安裝MySqlCentOS原始碼編譯
- mysql 原始碼安裝-5.7-17-19版本MySql原始碼
- 原始碼安裝openresty原始碼REST
- nginx原始碼安裝Nginx原始碼
- 原始碼安裝postgresql原始碼SQL
- Nginx 原始碼安裝Nginx原始碼
- 原始碼安裝GO原始碼Go
- PostgreSQL 10.12 安裝系列 - 原始碼安裝SQL原始碼
- 【推薦 - 原始碼安裝】nginx - 安裝原始碼Nginx
- Ubuntu 16.04下 Mysql5.7.17原始碼編譯與安裝UbuntuMySql原始碼編譯
- MYSQL5.6.40原始碼安裝 主從搭建 主主搭建MySql原始碼
- GDB 除錯 Mysql 實戰(一)原始碼編譯安裝除錯MySql原始碼編譯
- 基於Linux的MySQL5.7原始碼編譯安裝LinuxMySql原始碼編譯
- MYSQL5.7.22 原始碼安裝 主從搭建 + KEEPALIVED高可用MySql原始碼
- yum安裝與原始碼安裝比較原始碼
- linux安裝python3(原始碼安裝)LinuxPython原始碼
- paramiko 2.4.1原始碼安裝原始碼
- macbook 原始碼安裝 redisMac原始碼Redis
- macbook 原始碼安裝 nginxMac原始碼Nginx
- docker原始碼安裝NginxDocker原始碼Nginx
- 【PG安裝】postgresql10 for linux 原始碼安裝SQLLinux原始碼
- EOS原始碼分析(1)安裝原始碼
- PostgreSQL-原始碼安裝(一)SQL原始碼
- 原始碼編譯安裝Redis原始碼編譯Redis
- openeuler原始碼安裝Postgresql 16原始碼SQL
- 原始碼安裝Nginx和PHP原始碼NginxPHP
- 原始碼包安裝過程原始碼