(1)cmake是新版MySQL的編譯工具
創(chuàng)新互聯(lián)長(zhǎng)期為上1000+客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為建水企業(yè)提供專業(yè)的網(wǎng)站制作、做網(wǎng)站,建水網(wǎng)站改版等技術(shù)服務(wù)。擁有十載豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
sudo yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel sudo yum install zlib zlib-devel cmake ncurses ncurses-devel bison bison-devel 如下的幾個(gè)依賴在CentOS7中需要安裝,CentOS6不需要 sudo yum install perl perl-devel autoconf
如果安裝的MySQL5.7及以上的版本,在編譯安裝之前需要安裝boost,因?yàn)楦甙姹緈ysql需要boots庫(kù)的安裝才可以正常運(yùn)行。否則會(huì)報(bào)CMake Error at cmake/boost.cmake:81錯(cuò)誤
1.切換到/usr/local目錄,然后在這個(gè)目錄下下載boost
MySQL5.7.24要求boost的版本是1.59,更高版本的不適用MySQL5.7.24
wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
2.解壓并改名
tar zxvf boost_1_59_0.tar.gz mv boost_1_59_0 boost
3.在預(yù)編譯安裝MySQL時(shí)要加上-DWITH_BOOST=/usr/local/boost
# 添加MySQL用戶 useradd -s /sbin/nologin -M mysql # 下載MySQL wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24.tar.gz # 解壓MySQL tar zxvf mysql-5.7.24.tar.gz # 進(jìn)到MySQL目錄 cd mysql-5.7.24 # 預(yù)編譯 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.24 \ -DWITH_BOOST=/usr/local/boost \ -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.7.24/tmp/mysql.sock \ -DMYSQL_DATADIR=/usr/local/mysql-5.7.24/data \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DWITH_INNODB_MEMCACHED=1 \ -DWITH_DEBUG=OFF \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DENABLED_PROFILING=ON \ -DMYSQL_MAINTAINER_MODE=OFF \ -DMYSQL_TCP_PORT=3306 # 編譯&安裝 make && make install
# 創(chuàng)建軟連接 cd /usr/local ln -s mysql-5.7.24 mysql # 添加到環(huán)境變量 vim /etc/profile export PATH=/usr/local/mysql/bin:$PATH export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH source /etc/profile cd /usr/local/mysql-5.7.24 mkdir -p /usr/local/mysql-5.7.24/{data,tmp,logs,pids} chown mysql.mysql /usr/local/mysql-5.7.24/data chown mysql.mysql /usr/local/mysql-5.7.24/tmp chown mysql.mysql /usr/local/mysql-5.7.24/logs chown mysql.mysql /usr/local/mysql-5.7.24/pids # 修改/etc/my.cnf文件,編輯配置文件如下 [mysqld] character-set-server=utf8mb4 collation-server=utf8mb4_general_ci datadir=/usr/local/mysql/data socket=/usr/local/mysql/tmp/mysql.sock [mysqld_safe] log-error=/usr/local/mysql/logs/mysqld.log pid-file=/usr/local/mysql/pids/mysqld.pid [client] default-character-set=utf8mb4 # 創(chuàng)建mysqld.log 和 mysqld.pid文件 touch /usr/local/mysql/logs/mysqld.log touch /usr/local/mysql/pids/mysqld.pid chown mysql.mysql -R /usr/local/mysql/logs/ chown mysql.mysql -R /usr/local/mysql/pids/ # 加入守護(hù)進(jìn)程 cd /usr/local/mysql cp support-files/mysql.server /etc/init.d/mysqld chmod a+x /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on # 初始化數(shù)據(jù)庫(kù), –initialize 表示默認(rèn)生成一個(gè)安全的密碼,–initialize-insecure 表示不生成密碼 mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data # 啟動(dòng)MySQL service mysqld start
這里給一張/etc/my.cnf的配置圖示
登錄MySQL,修改密碼
mysql -u root -p #第一次登陸不需要密碼,回車即可 set password for root@localhost = password('root'); #修改密碼
總結(jié)
以上所述是小編給大家介紹的CentOS7編譯安裝MySQL5.7.24的教程詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!