標籤:nbsp 儲存引擎 檔案路徑 日誌 srcdir aries memory 日誌記錄 myisam
在 linux 上編譯安裝 mysql-5.6.28.tar.gzhttp://www.mysql.com/mysql:http://www.mysql.com/downloads/mysql/#downloadsmysql 官方網站文檔:https://dev.mysql.com/doc/01、準備工作yum install -y gcc gcc-c++ cmake make ncurses ncurses-devel bison02、解壓tar zxf mysql-5.6.28.tar.gz03、編譯cmake . -DCMAKE_INSTALL_PREFIX=/tmp/test/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_cimake -j 8make install -j 8 注意:常見的CMAKE選項-DCMAKE_INSTALL_PREFIX=/usr/local/mysql MySQL安裝目錄-DWITH_INNOBASE_STORAGE_ENGINE=1 安裝InnoDB儲存引擎-DWITH_MYISAM_STORAGE_ENGINE=1 安裝MyISAM儲存引擎-DWITH_MEMORY_STORAGE_ENGINE=1 安裝記憶體儲存引擎-DDEFAULT_CHARSET=utf8 預設編碼設定成utf8-DDEFAULT_COLLATION=utf8_general_ci 默然校正規則是utf8_general_ci-DWITH_EXTRA_CHARSETS=all 支援其他所有的編碼-DMYSQL_TCP_PORT=3306 MySQL連接埠指定為3306-DMYSQL_UNIX_ADDR=/tmp/mysql.sock 指定SOCK檔案路徑-DMYSQL_DATADIR=/usr/local/mysql/data MySQL資料目錄make -j n 支援多線程編譯(一般跟核心數相等)04、配置my.cnf[[email protected] mysql]# pwd/tmp/test/mysqlmkdir conf cp support-files/my-default.cnf conf/vim my.cnf 詳情看下面的附屬
05、初始化資料庫useradd mysql#注意 --user 需要用root編譯./scripts/mysql_install_db --defaults-file=/tmp/test/mysql/my.cnf --user=mysql./scripts/mysql_install_db --defaults-extra-file=/tmp/test/mysql/conf/my.cnf --user=mysql06、啟動資料庫./bin/mysqld_safe --defaults-file=/tmp/test/mysql/my.cnf --user=mysql &./bin/mysqld_safe --defaults-extra-file=/tmp/test/mysql/conf/my.cnf --user=mysql &07、設定密碼[[email protected] ~]# ss -ln |grep 3333LISTEN 0 80 :::3333 :::* ./bin/mysqladmin -u root password ‘123123‘08、賬戶授權grant all on *.* to ‘mvpbang‘@‘%‘ identified by ‘123123‘;flush privileges;09、設定系統內容變數vim /etc/profileexport PATH=$PATH://tmp/test/mysql/binsource /etc/profile修改 rc.local ,讓 mysql 開機自動運行echo "mysqld_safe --defaults-extra-file=/tmp/test/mysql/conf/my.cnf --user=mysql &" >>/etc/rc.local10、基本命令的參數說明[[email protected] mysql]# ./scripts/mysql_install_db --helpUsage: ./scripts/mysql_install_db [OPTIONS] --basedir=path The path to the MySQL installation directory. --builddir=path If using --srcdir with out-of-directory builds, you will need to set this to the location of the build directory where built files reside. --cross-bootstrap For internal use. Used when building the MySQL system tables on a different host than the target. --datadir=path The path to the MySQL data directory. If missing, the directory will be created, but its parent directory must already exist and be writable. --defaults-extra-file=name Read this file after the global files are read. --defaults-file=name Only read default options from the given file name. --force Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses. --help Display this help and exit. --ldata=path The path to the MySQL data directory. Same as --datadir. --no-defaults Don‘t read default options from any option file. --keep-my-cnf Don‘t try to create my.cnf based on template. Useful for systems with working, updated my.cnf. Deprecated, will be removed in future version. --random-passwords Create and set a random password for all root accounts and set the "password expired" flag, also remove the anonymous accounts. --rpm For internal use. This option is used by RPM files during the MySQL installation process. --skip-name-resolve Use IP addresses rather than hostnames when creating grant table entries. This option can be useful if your DNS does not work. --srcdir=path The path to the MySQL source directory. This option uses the compiled binaries and support files within the source tree, useful for if you don‘t want to install MySQL yet and just want to create the system tables. --user=user_name The login username to use for running mysqld. Files and directories created by mysqld will be owned by this user. You must be root to use this option. By default mysqld runs using your current login name and files and directories that it creates will be owned by you.Any other options are passed to the mysqld program.[[email protected] mysql]# ./bin/mysqld_safe --helpUsage: ./bin/mysqld_safe [OPTIONS] --no-defaults Don‘t read the system defaults file --defaults-file=FILE Use the specified defaults file --defaults-extra-file=FILE Also use defaults from the specified file --ledir=DIRECTORY Look for mysqld in the specified directory --open-files-limit=LIMIT Limit the number of open files --core-file-size=LIMIT Limit core files to the specified size --timezone=TZ Set the system timezone --malloc-lib=LIB Preload shared library LIB if available --mysqld=FILE Use the specified file as mysqld --mysqld-version=VERSION Use "mysqld-VERSION" as mysqld --nice=NICE Set the scheduling priority of mysqld --plugin-dir=DIR Plugins are under DIR or DIR/VERSION, if VERSION is given --skip-kill-mysqld Don‘t try to kill stray mysqld processes --syslog Log messages to syslog with ‘logger‘ --skip-syslog Log messages to error log (default) --syslog-tag=TAG Pass -t "mysqld-TAG" to ‘logger‘All other options are passed to the mysqld program.
附上my.cnf
[client]default-character-set=utf8[mysql]auto-rehashdefault-character-set=utf8[mysqld]#根據實際情況適當調整innodb_buffer_pool_size = 128Mjoin_buffer_size = 128Msort_buffer_size = 2Mread_rnd_buffer_size = 2M #個人化lower_case_table_names=1 #忽略大小寫 #對大批量資料匯入匯出防止逾時max_allowed_packet=500Mwait_timeout=200000interactive_timeout=200000#資料庫字元集設定(由於編譯已經選擇,顧不需要設定)#init_connect=‘SET collation_connection = utf8_unicode_ci‘#init_connect=‘SET NAMES utf8‘#character-set-server=utf8#collation-server=utf8_unicode_ci#日誌記錄#log_bin#基本資料basedir = /tmp/test/mysqldatadir = /tmp/test/mysql/dataport = 3333server_id = 1socket = /tmp/test/mysql/data/mysql.socksql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqld_safe]log-error = /tmp/test/mysql/life.logpid-file = /tmp/test/mysql/data/mysqld.pid
核心編譯進度
注意:配置低的編譯基本上都是1個小時左右!!!(一般建議放在伺服器上編譯開多線程)
linux上源碼編譯安裝mysql-5.6.28