mysql-源碼包安裝
阿新 • • 發佈:2018-06-18
安裝 pil IT ali pro p s add lib include 源碼包安裝mysql:
1、下載源碼包 www.mysql.com
# md5sum mysql-5.6.25.tar.gz
37664399c91021abe070faa700ecd0ed mysql-5.6.25.tar.gz
2、解壓並且進入到解壓的目錄
# tar -xf mysql-5.6.25.tar.gz
# cd mysql-5.6.25
創建mysql用戶:
# groupadd mysql
# useradd -r -g mysql -s /bin/false mysql
3、安裝三步曲(配置、編譯、安裝)
需求:
安裝目錄:/mysql25
數據目錄:/mysql25/data
端口:3308
sock:/mysql25/mysql.sock
CMAKE_INSTALL_PREFIX=/mysql25 指定安裝基目錄
DEFAULT_CHARSET= 默認的字符集
DEFAULT_COLLATION= 字符集的排序
ENABLED_LOCAL_INFILE= 是否加載外部文件 默認off 1代表開啟;0代表關閉
MYSQL_TCP_PORT 端口號
MYSQL_UNIX_ADDR 指定sock文件位置
SYSCONFDIR 系統配置文件所在路徑
MYSQL_DATADIR 數據庫的數據目錄
WITH_EXTRA_CHARSETS 擴展字符集
WITHOUT_xxx_STORAGE_ENGINE 不將存儲引擎編譯到mysql的靜態庫裏
WITH_xxx_STORAGE_ENGINE 將存儲引擎編譯到mysql的靜態庫裏
# vim cmake.sh
---> cmake .
-DCMAvimKE_INSTALL_PREFIX=/mysql25 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/mysql25/data -DSYSCONFDIR=/mysql25/ -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 \ 支持分區
-DMYSQL_UNIX_ADDR=/mysql25/mysql.socket -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3308
# chmod o+x cmake.sh
【或者# cmake . -DCMAKE_INSTALL_PREFIX=/mysql25 -DENABLED_LOCAL_INFILE=1...】
準備工作:
# yum -y install cmake
# mkdir /mysql25
# chown -R mysql. /mysql25
錯誤提示:
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:85 (MESSAGE):
Curses library not found. Please install appropriate package,
解決:安裝所需要的軟件包:
# yum -y install ncurses-devel
# rm -f CMakeCache.txt
# bash cmake.sh
# make
# make install
# scripts/mysql_install_db --user=mysql----初始化數據庫
建mysql25的啟動腳本文件
# cp support-files/mysql.server /etc/init.d/mysql25
註意:
修改腳本文件中的(vim /etc/init.d/mysql25)
basedir=/usr/local/mysql25
datadir=/usr/local/mysql25/data
9、用腳本再次測試驗證
# /etc/init.d/mysql25---腳本啟動
# service mysql25 restart
初始化:
登錄:
# export PATH=$PATH:/usr/local/mysql25/bin
# /usr/local/mysql25/bin/mysql------進入mysql
字符集和字符編碼:
字符:所有符號的總稱
字符集:
unicode(統一字符集):
ASCII:
GB2312:中文字符集
GBK:gb2312的擴展字符集
GB18030:gbk的超級字符集,包含中、日、韓三個國家的字符集
字符編碼:
UTF-8 UTF-16 UCS-2 UCS-4
GBK/GB2312
GB18030
字符編碼 每個字符字節數
ASCCii 1
UTF-8(UNICODE) 1-6
UTF-16 2-4
GBK/GB2312 1-2
GB18030 1-4
錯誤提示:
CMake Error at /usr/share/cmake/Modules/CMakeCXXInformation.cmake:17 (GET_FILENAME_COMPONENT):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
CMakeLists.txt:3 (PROJECT)
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Performing Test HAVE_PEERCRED - Failed
解決:
yum -y install gcc-*
/soft/mysql-5.6.25/sql/sql_planner.cc: In member function ‘void Optimize_table_order::best_access_path(JOIN_TAB*, table_map, uint, bool, double, POSITION*, POSITION*)’:
/soft/mysql-5.6.25/sql/sql_planner.cc:431: warning: ‘loose_scan_opt.Loose_scan_opt::best_loose_scan_start_key’ may be used uninitialized in this functio
Starting MySQL..The server quit without updating PID file (/mysql25/data/zy.uplooking.com.pid).
mysql-源碼包安裝