CentOS6.9+Mysql5.7.18源碼安裝詳細(xì)教程
CentOS6.9+Mysql5.7.18源碼安裝,以下操作均在root用戶下執(zhí)行。
1、安裝依賴工具
cmake make3.75+ gcc4.4.6+ Boost1.59.0 bison ncurses yum install -y cmake,make,gcc,gcc-c++,bison, ncurses,ncurses-devel cd /opt
wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
或者向度娘要一個(gè)
tar -zxvf boost_1_59_0.tar.gz -C /usr/local/
2、下載mysql準(zhǔn)備安裝
git clone https://github.com/mysql/mysql-server.git
沒(méi)有g(shù)it就 yum install git裝一個(gè)
選擇5.7
創(chuàng)建mysql用戶,用戶組為root
useradd -r -g root -s /bin/false mysql
3、執(zhí)行cmake
cd /opt/mysql-server5.7 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DWITH_BOOST=/usr/local/boost_1_59_0 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DSYSCONFDIR=/etc \ -DEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DENABLED_LOCAL_INFILE=1 \ -DEXTRA_CHARSETS=all -DCMAKE_INSTALL_PREFIX:安裝路徑-DMYSQL_DATADIR:數(shù)據(jù)存放目錄-DWITH_BOOST:boost源碼路徑-DSYSCONFDIR:my.cnf配置文件目錄-DEFAULT_CHARSET:數(shù)據(jù)庫(kù)默認(rèn)字符編碼-DDEFAULT_COLLATION:默認(rèn)排序規(guī)則-DENABLED_LOCAL_INFILE:允許從本文件導(dǎo)入數(shù)據(jù)-DEXTRA_CHARSETS:安裝所有字符集 4、編譯安裝 make -j `grep processor /proc/cpuinfo | wc -l` make install -j參數(shù)表示根據(jù)CPU核數(shù)指定編譯時(shí)的線程數(shù),可以加快編譯速度。 如果中途編譯失敗了,需要?jiǎng)h除cmake生成的預(yù)編譯配置參數(shù)的緩存文件和make編譯后生成的文件,再重新編譯。 cd /opt/mysql-server5.7 rm -f CMakeCache.txt make clean
5、初始化系統(tǒng)數(shù)據(jù)庫(kù)
vim /etc/my.cnf
進(jìn)入insert模式,將原來(lái)內(nèi)容替換成如下內(nèi)容:
[client] port=3306 socket=/temp/mysql.sock [mysqld] character-set-server=utf8 collation-server=utf8_general_ci skip-external-locking skip-name-resolve user=mysql port=3306 basedir=/usr/local/mysql datadir=/usr/local/mysql/data tmpdir=/usr/local/mysql/temp # server_id = ..... socket=/usr/local/mysql/mysql.sock log-error=/usr/local/mysql/logs/mysql_error.log pid-file=/usr/local/mysql/mysql.pid open_files_limit=10240 back_log=600 max_connections=500 max_connect_errors=6000 wait_timeout=605800 #open_tables=600 #table_cache = 650 #opened_tables = 630 max_allowed_packet=32M sort_buffer_size=4M join_buffer_size=4M thread_cache_size=300 query_cache_type=1 query_cache_size=256M query_cache_limit=2M query_cache_min_res_unit=16k tmp_table_size=256M max_heap_table_size=256M key_buffer_size=256M read_buffer_size=1M read_rnd_buffer_size=16M bulk_insert_buffer_size=64M lower_case_table_names=1 default-storage-engine=INNODB innodb_buffer_pool_size=2G innodb_log_buffer_size=32M innodb_log_file_size=128M innodb_flush_method=O_DIRECT ##################### thread_concurrency=32 long_query_time=2 slow-query-log=on slow-query-log-file=/usr/local/mysql/logs/mysql-slow.log [mysqldump] quick max_allowed_packet=32M [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid cd /usr/local/mysql mkdir data mkdir logs mkdir temp chmod 0770 -R . ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --socket=/tmp/mysql.sock
在MySQL 5.7.6版本以前是 bin/mysql_install_db --user
執(zhí)行完成后,查看 logs/mysql_error.log文件,將里面的臨時(shí)root密碼記下來(lái)
A temporary password is generated for root@localhost: xxxxxxxxxx
6、配置mysql
chkconfig --add mysqld # 添加到系統(tǒng)服務(wù) chkconfig mysqld on # 開(kāi)機(jī)啟動(dòng) service mysqld start啟動(dòng)不成功,使用safe模式啟動(dòng) chown -R mysql:root /var/run/mysqld ./bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql & ./mysql -uroot -p
輸入mysql_error.log中的臨時(shí)密碼登入mysql控制臺(tái)
set password='asdfghjkl''; Query OK, 0 rows affected (0.00 sec) show warnings;
停止mysql
mysqladmin -u root -p shutdown
輸入剛才設(shè)置的密碼,停止成功
接下來(lái)可以使用系統(tǒng)服務(wù)來(lái)啟動(dòng)mysql了:
service mysqld start # 啟動(dòng)mysql服務(wù)
以上所述是小編給大家介紹的CentOS6.9+Mysql5.7.18源碼安裝,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)本站網(wǎng)站的支持!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信