新聞中心
MySQL是世界上最受歡迎的開源數(shù)據(jù)庫(kù)。MySQL 5.7 是MySQL到目前為止的最好的發(fā)布,5.7提供了一個(gè)新的高級(jí)的功能集,下面為大家分享一下Centos7.2 Systemd 方式編譯 Mysql5.7.11具體方法。

網(wǎng)站的建設(shè)創(chuàng)新互聯(lián)建站專注網(wǎng)站定制,經(jīng)驗(yàn)豐富,不做模板,主營(yíng)網(wǎng)站定制開發(fā).小程序定制開發(fā),H5頁(yè)面制作!給你煥然一新的設(shè)計(jì)體驗(yàn)!已為成都混凝土攪拌機(jī)等企業(yè)提供專業(yè)服務(wù)。
MySQL 5.7主要特性:
原生支持Systemd 更好的性能:對(duì)于多核CPU、固態(tài)硬盤、鎖有著更好的優(yōu)化 更好的InnoDB存儲(chǔ)引擎 更為健壯的復(fù)制功能:復(fù)制帶來了數(shù)據(jù)完全不丟失的方案,傳統(tǒng)金融客戶也可以選擇使用MySQL數(shù)據(jù)庫(kù)。此外,GTID在線平滑升級(jí)也變得可能 更好的優(yōu)化器:優(yōu)化器代碼重構(gòu)的意義將在這個(gè)版本及以后的版本中帶來巨大的改進(jìn),Oracle官方正在解決MySQL之前最大的難題 原生JSON類型的支持 更好的地理信息服務(wù)支持:InnoDB原生支持地理位置類型,支持GeoJSON,GeoHash特性 新增sys庫(kù):以后這會(huì)是DBA訪問最頻繁的庫(kù) MySQL 5.7已經(jīng)作為數(shù)據(jù)庫(kù)可選項(xiàng)添加到 OneinStack — lnmp 安裝工具中
安裝依賴包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
下載mysql源碼包
源碼包有兩種版本 : mysql-5.7.11.tar.gz 不帶 boost庫(kù) ,需要自行下載。
mysql-boost-5.7.11.tar.gz 自帶 boost庫(kù),在解壓后的根目錄,推薦下載。 wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz
curl -O http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz
tar -zxf mysql-boost-5.7.11.tar.gz
cd mysql-5.7.11
編譯
生成makefile“
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ [字符集] -DDEFAULT_COLLATION=utf8_general_ci \ [排序規(guī)則 必須有,不然初始化數(shù)據(jù)庫(kù)困難] -DDOWNLOAD_BOOST=1 \ [從MySQL 5.7.5開始Boost庫(kù)是必需的] -DWITH_BOOST=/root/mysql-5.7.11/boost \ -DWITH_SYSTEMD=1 [支持Systemd] 加上-DWITH_SYSTEMD=1可以使用systemd控制mysql服務(wù),默認(rèn)是不開啟systemd的。
然后 make -j 2 && make install mysql將會(huì)安裝到/usr/local/mysql路徑 慢慢等……
配置MySQL
添加mysql用戶和組
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
修改/usr/local/mysql權(quán)限
chown -R mysql:mysql /usr/local/mysql
創(chuàng)建 mysql PID 默認(rèn)目錄
在 mysqld.service ,把默認(rèn)的pid文件指定到了 /var/run/mysqld/ 目錄,而并沒有事先建立該目錄,因此要手動(dòng)建立該目錄并把權(quán)限賦給 mysql 用戶。 mkdir -p /var/run/mysqldchown mysql:mysql /var/run/mysqld
mysql 三個(gè)運(yùn)行文件默認(rèn)位置
log : /var/log/mysqld.logpid : /var/run/mysqld/mysqld.pidsock : /tmp/mysql.sock
拷貝 my.cnf 和 mysqld.service
cp support-files/my-default.cnf /etc/my.cnf
mysql 5.7 默認(rèn)將 mysqld.service (/usr/local/mysql/)文件安裝到了 mysql 安裝目錄下的 usr/lib/systemd/system/,將 mysqld.service 復(fù)制到/usr/lib/systemd/system/目錄下 [root@localhost]/usr/local/mysql#cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system
添加環(huán)境變量
— 編輯/etc/profile文件在最后添加如下兩行 — “
vim /etc/profile
PATH=/usr/local/mysql/bin:$PATH export PATH
source /etc/profile
初始化 無(wú)密碼 mysql 數(shù)據(jù)庫(kù)
bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/databin/mysql_ssl_rsa_setup 出現(xiàn)下列內(nèi)容,初始化成功 2016-02-22T03:56:27.254356Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the –initialize-insecure option.
-–initialize 會(huì)生成一個(gè)隨機(jī)密碼(保存在~/.mysql_secret),而 -–initialize-insecure 不會(huì)生成密碼,在MySQL安全配置向?qū)ysql_secure_installation設(shè)置密碼時(shí),可自由選擇 mysql 密碼等級(jí)。
-–datadir目標(biāo)目錄下不能有數(shù)據(jù)文件。
之前版本初始化程序 mysql_install_db 是在 /usr/local/mysql/script 下,并會(huì)在將來被移除,轉(zhuǎn)而使用mysqld替代 已被廢棄 mysql5.7 放在了 /usr/local/mysql/bin 目錄下。
啟動(dòng) mysql
systemctl start mysqld.service
systemctl status mysqld.service
運(yùn)行 MySQL安全配置向?qū)ysql_secure_installation 設(shè)置密碼,mysql 服務(wù)啟動(dòng)后才可執(zhí)行
a)為root用戶設(shè)置密碼 b)刪除匿名賬號(hào) c)取消root用戶遠(yuǎn)程登錄 d)刪除test庫(kù)和對(duì)test庫(kù)的訪問權(quán)限 e)刷新授權(quán)表使修改生效 [root@localhost mysql]# mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password. [使用空密碼連接到MySQL]
VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin?[VALIDATE密碼插件可以被用來測(cè)試密碼 并提高安全性。你是否想設(shè)置VALIDATE密碼插件?]
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy: [有三種級(jí)別的密碼驗(yàn)證策略:]
LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file [最小長(zhǎng)度> = 8 中等長(zhǎng)度> = 8,數(shù)字,大小寫混合和特殊字符 最長(zhǎng)長(zhǎng)度> = 8,數(shù)字,混合大小寫,特殊字符和字典文件]
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 [請(qǐng)輸入0 =低,1 =中2 =強(qiáng):0] Please set the password for root here. [請(qǐng)?jiān)谶@里設(shè)置root用戶的密碼。]
New password: [新密碼:]
Re-enter new password: [重新輸入新密碼:]
Estimated strength of the password: 25 [密碼的估計(jì)強(qiáng)度:25] Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y [您是否希望繼續(xù)與提供的密碼(按y | Y表示是,因?yàn)闆]有任何其他鍵):Y?] … Failed! Error: Your password does not satisfy the current policy requirements [ … 失敗!錯(cuò)誤:您的密碼不符合當(dāng)前的要求]
New password:
Re-enter new password:
Estimated strength of the password: 50 [密碼的估計(jì)強(qiáng)度:50] Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. [默認(rèn)情況下,MySQL安裝有一個(gè)匿名用戶, 允許任何人登錄到MySQL.]
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y [刪除匿名用戶?] Success. [成功。]
Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network. [通常情況下,Root 只允許其進(jìn)行’localhost'(本地) 連接 。]
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n [禁止遠(yuǎn)程root登錄?]
… skipping. […跳過。] By default, MySQL comes with a database named ‘test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. [默認(rèn)情況下,MySQL帶有一個(gè)名為“測(cè)試”數(shù)據(jù)庫(kù),任何人都可以訪問。這也是僅用于測(cè)試,并且應(yīng)該移動(dòng)到生產(chǎn)之前被刪除環(huán)境。]
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n [刪除測(cè)試數(shù)據(jù)庫(kù)和訪問權(quán)限?]
… skipping. [ …跳過。] Reloading the privilege tables will ensure that all changes made so far will take effect immediately. [刷新授權(quán)表以確保所有的變化取得將立即生效。]
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : [現(xiàn)在刷新授權(quán)表?]
… skipping. All done! [全部完成!]
開放 Root 遠(yuǎn)程連接權(quán)限
mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; [password 為遠(yuǎn)程連接密碼]
mysql>FLUSH PRIVILEGES; [刷新權(quán)限]
網(wǎng)頁(yè)標(biāo)題:通過Systemd方式編譯Mysql5.7.11
當(dāng)前鏈接:http://m.fisionsoft.com.cn/article/cdsojoj.html


咨詢
建站咨詢
