【MySQL】Linux下MySQL 5.5绢馍、5.6和5.7的RPM、二進制和源碼安裝
1.1BLOG文檔結(jié)構(gòu)圖
1.2前言部分
1.2.1導(dǎo)讀和注意事項
各位技術(shù)愛好者肠套,看完本文后舰涌,你可以掌握如下的技能,也可以學(xué)到一些其它你所不知道的知識你稚,~O(∩_∩)O~:
①MySQL的二進制安裝過程(重點)
② MySQL多實例管理(mysqld_multi)
③MySQL的源碼編譯安裝過程
④Linux的邏輯卷的使用
⑤文件的MD5值
⑥訪問MySQL的幾種客戶端工具(Navicat和MySQLWorkbench)
⑦ 修改MySQL的密碼
⑧ 設(shè)置MySQL的遠程訪問
⑨ 設(shè)置MySQL的開機啟動以及多實例的開機啟動
⑩RPM瓷耙、二進制和源碼編譯的優(yōu)缺點
Tips:
①本文在itpub(http://blog.itpub.net/26736162)、博客園(http://www.cnblogs.com/lhrbest)和微信公眾號(xiaomaimiaolhr)上有同步更新刁赖。
②文章中用到的所有代碼搁痛、相關(guān)軟件、相關(guān)資料及本文的pdf版本都請前往小麥苗的云盤下載宇弛,小麥苗的云盤地址見:http://blog.itpub.net/26736162/viewspace-1624453/落追。
③若網(wǎng)頁文章代碼格式有錯亂,請下載pdf格式的文檔來閱讀涯肩。
④在本篇BLOG中轿钠,代碼輸出部分一般放在一行一列的表格中。
⑤ 本文適合于MySQL初中級人員閱讀病苗,MySQL大師請略過本文疗垛。
⑥ 不喜勿噴。
本文若有錯誤或不完善的地方請大家多多指正硫朦,您的批評指正是我寫作的最大動力贷腕。
-------------------------------------------------------------------------
1.3本文簡介
自從去年3月份開始寫書到現(xiàn)在,基本上大部分內(nèi)容都寫完了咬展。一個字泽裳,累!三個字破婆,真心累涮总!我也因此錯過了很多的東西柜裸,當(dāng)然也收獲了很多玷犹,一切都隨緣吧。現(xiàn)在來說說博客吧猾封,雖然我的博客在這段時間更新比較頻繁裳扯,但是大多內(nèi)容都不是來自我的原創(chuàng)抛丽,基本都是整理自網(wǎng)絡(luò)∈尾颍可能有的朋友就會罵小麥苗了亿鲜,抄襲抄襲,我不反駁冤吨,因為這的確是抄襲蒿柳。為啥小麥苗要這么做,可能基于這么幾個原因吧锅很。第一其馏,干貨類的文章,本來原創(chuàng)的內(nèi)容就少爆安,網(wǎng)上的文章也大多是一個抄一個的叛复,很多內(nèi)容,原創(chuàng)作者已經(jīng)很難找到了扔仓。第二褐奥,個別文章并不是很完善,如果不整理在一塊翘簇,若下次碰到相同的內(nèi)容撬码,還是得網(wǎng)上再天翻地覆的搜一遍,太浪費時間了版保。第三呜笑,這些非原創(chuàng)的文章夫否,不僅僅是給網(wǎng)友做參考,更重要的是叫胁,小麥苗自己也參考凰慈。畢竟人的記憶力是有限的,小麥苗也經(jīng)常搜索自己的文章驼鹅,所以微谓,這并不可恥。第四输钩,有的文章寫得很好豺型,但是里邊有個別地方寫得不嚴謹,或者寫得有錯誤买乃,這個時候姻氨,小麥苗整理到自己博客的時候就可以順便修改過來。說再多为牍,有的網(wǎng)友覺得哼绑,這都是借口,好吧碉咆。抄襲就是抄襲抖韩,再多借口也改變不了抄襲的本質(zhì)。小麥苗不再多說了疫铜,只想說一句茂浮,不喜勿噴。
從今天開始壳咕,小麥苗會準備OCM和MySQL的學(xué)習(xí)席揽。所以,今天就先把MySQL的各個版本安裝一下吧谓厘。要學(xué)習(xí)MySQL幌羞,估計5.5、5.6和5.7版本的都需要安裝竟稳。不過属桦,相比Oracle而言,MySQL還是更好安裝一點他爸。
小麥苗出版的書籍:http://blog.itpub.net/26736162/viewspace-2142121/
廢話已經(jīng)說了很多了聂宾,下面開始安裝吧。
1.4Linux下各種安裝方法比較
在Windows下可以使用NOINSTALL包和圖形化包來安裝诊笤,在Linux下可以使用如下3種方式來安裝:
RPM(Redhat Package Manage)
二進制(Binary Package)
源碼(Source Package)
優(yōu)點
安裝簡單系谐,適合初學(xué)者學(xué)習(xí)使用
安裝簡單;可以安裝到任何路徑下讨跟,靈活性好纪他;一臺服務(wù)器可以安裝多個MySQL
在實際安裝的操作系統(tǒng)進行可根據(jù)需要定制編譯鄙煤,最靈活;性能最好止喷;一臺服務(wù)器可以安裝多個MySQL
缺點
需要單獨下載客戶端和服務(wù)器馆类;安裝路徑不靈活,默認路徑不能修改弹谁,一臺服務(wù)器只能安裝一個MySQL
已經(jīng)經(jīng)過編譯,性能不如源碼編譯的好句喜;不能靈活定制編譯參數(shù)
安裝過程較復(fù)雜预愤;編譯時間長
文件布局
/usr/bin:客戶端程序和腳本
/usr/sbin:mysqld服務(wù)器
/var/lib/mysql:日志文件,數(shù)據(jù)庫
/usr/share/doc/packages:文檔
/usr/include/mysql:包含(頭)文件
/usr/lib/mysql:庫文件
/usr/share/mysql:錯誤消息和字符集文件
/usr/share/sql-bench:基準程序bin:客戶端程序和mysqld服務(wù)器
data:日志文件咳胃,數(shù)據(jù)庫
docs:文檔植康,ChangeLog
include:包含(頭)文件
lib:庫
scripts:mysql_install_db用來初始化系統(tǒng)數(shù)據(jù)庫
share/mysql:錯誤消息文件
sql-bench:基準程序bin:客戶端程序和腳本
include/mysql:包含(頭)文件
info:Info格式的文檔
lib/mysql:庫文件
libexec:mysqld服務(wù)器
share/mysql:錯誤消息文件
sql-bench:基準程序和crash-me測試
var:數(shù)據(jù)庫和日志文件
主要安裝過程
在大多數(shù)情況下,下載MySQL-server和MySQL-client就可以了展懈,安裝方法如下:
rpm -ivh MySQL-server*MySQL-client*1.添加用戶
groupadd mysql
useradd -g mysql mysql
2.安裝
tar -xzvf mysql-VERSION-OS.tar.gz -C /mysql/
ln -s MySQL-VERSION-OS mysql或用mv命令
3.初始化销睁,MySQL 5.7之后用mysqld --initialize
scripts/mysql_install_db
4.啟動數(shù)據(jù)庫并修改密碼等
mysqld_safe &
set password=password('lhr');除了第二步的安裝過程外,其它步驟和二進制基本一樣(MySQL 5.7開始使用cmake):
gunzip < mysql-VERSION.tar.gz | tar -xvf -
cd mysql-VERSION
./configure --prefix=/usr/local/mysql
make&&make install
安裝包下載選項
Red Hat Enterprise Linux/Oracle Linux
Linux-Generic
Source Code
rpm的安裝方式請參考:
http://blog.itpub.net/26736162/viewspace-1349705/
http://blog.itpub.net/26736162/viewspace-1349787/
官網(wǎng)中相應(yīng)地有以上三種方式對應(yīng)的下載鏈接存崖,其中源碼安裝冻记,對應(yīng)"Source Code";.tar.gz對應(yīng)"Linux-Generic"来惧,.rpm則對應(yīng)于"Red Hat Enterprise Linux/Oracle Linux"冗栗,如下圖所示,
1.5注意事項
1.目錄大小供搀。MySQL 5.7的二進制安裝后大約3G,所以可以分配5G空間撒遣;而5.5和5.6版本的二進制包安裝可以分配2G左右。
2.MySQL 5.7的源碼包需要分配10G的空間层释。cmake最低需要2.8.2版本婆瓜。
3.下載和上傳后需要校驗md5值,防止上傳的文件不完整贡羔。
4.源碼編譯安裝比較費時費力廉白。
1.6MySQL下載
在官網(wǎng):http://dev.mysql.com/downloads/mysql/中,選擇以下版本的MySQL下載:
注意:MD5:dbe7e5e820377c29d8681005065e5728乖寒,下載完成后需要校驗猴蹂。
感覺MySQL的安裝包越來越大了,不過相比Oracle而言宵统,就小的多了晕讲。小麥苗已經(jīng)將安裝文件放到云盤了,參考:http://blog.itpub.net/26736162/viewspace-1624453/马澈。
注意:不要下載rpm類型的包府适,安裝路徑不靈活祟绊,默認路徑不能修改,一臺服務(wù)器只能MySQL安裝一個MySQL。下圖下載后均是rpm包:
1.6.1歷史MySQL版本下載
地址:https://downloads.mysql.com/archives/community/菩佑,最早版本只能看到5.0.15
1.7MySQL 5.7安裝
1.7.1下載
在官網(wǎng):http://dev.mysql.com/downloads/mysql/中屠升,選擇以下版本的MySQL下載:
注意:MD5:dbe7e5e820377c29d8681005065e5728谒所,下載完成后需要校驗徙菠。
1.7.2OS路徑設(shè)置
我們約定:
項目
source db
db類型
MySQL 5.7.19
db version
5.7.19
db存儲
Linux文件系統(tǒng)
OS版本及kernel版本
RHEL 6.5
OS主機名
LHRDB
OS IP地址
192.168.59.159
安裝文件下載目錄
/tmp/mysql5719
MySQL目錄安裝位置
/var/lib/mysql57/mysql5719
數(shù)據(jù)庫保存位置
/var/lib/mysql57/mysql5719/data
日志保存位置
/var/lib/mysql57/mysql5719/log
配置文件地址
/etc/my.cnf
需要注意的是,安裝文件解壓后大小大約為2.6G凝果,比MySQL 5.6大多了祝迂,我記得5.6版本解壓后還不到1G。所以器净,這里安裝目錄給5G大小型雳。
下面開始準備OS。使用以前就安裝好的OS,文件系統(tǒng)采用邏輯卷的管理方式纠俭,如下所示:
[root@LHRDB ~]# df -h
Filesystem??????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00? 9.9G? 4.9G? 4.6G? 52% /
tmpfs???????????????????????? 2.0G?? 72K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01? 3.0G?? 70M? 2.8G?? 3% /tmp
/dev/mapper/vg_rootlhr-Vol03? 3.0G?? 69M? 2.8G?? 3% /home
.host:/?????????????????????? 331G? 272G?? 59G? 83% /mnt/hgfs
[root@LHRDB ~]#lvs
LV??? VG???????? Attr?????? LSize? Pool Origin Data%? Move Log Cpy%Sync Convert
Vol00 vg_rootlhr -wi-ao---- 10.00g
Vol01 vg_rootlhr -wi-ao----? 3.00g
Vol02 vg_rootlhr -wi-ao----? 2.00g
Vol03 vg_rootlhr -wi-ao----? 3.00g
[root@LHRDB ~]#pvs
PV???????? VG???????? Fmt? Attr PSize? PFree
/dev/sda2? vg_rootlhr lvm2 a--? 10.00g???? 0
/dev/sda3? vg_rootlhr lvm2 a--?? 9.80g? 1.80g
/dev/sdb1???????????? lvm2 a--? 10.00g 10.00g
/dev/sdb10??????????? lvm2 a--? 10.00g 10.00g
/dev/sdb11??????????? lvm2 a--?? 9.99g? 9.99g
/dev/sdb2???????????? lvm2 a--? 10.00g 10.00g
/dev/sdb3???????????? lvm2 a--? 10.00g 10.00g
/dev/sdb5???????????? lvm2 a--? 10.00g 10.00g
/dev/sdb6???????????? lvm2 a--? 10.00g 10.00g
/dev/sdb7???????????? lvm2 a--? 10.00g 10.00g
/dev/sdb8???????????? lvm2 a--? 10.00g 10.00g
/dev/sdb9???????????? lvm2 a--? 10.00g 10.00g
[root@LHRDB ~]#vgs
VG???????? #PV #LV #SN Attr?? VSize? VFree
vg_rootlhr?? 2?? 4?? 0 wz--n- 19.80g 1.80g
[root@LHRDB ~]#vgcreate vg_mysqlsoft /dev/sdb1
Volume group "vg_mysqlsoft" successfully created
[root@LHRDB ~]# vgs
VG?????????? #PV #LV #SN Attr?? VSize? VFree
vg_mysqlsoft?? 1?? 0?? 0 wz--n- 10.00g 10.00g
vg_rootlhr???? 2?? 4?? 0 wz--n- 19.80g? 1.80g
[root@LHRDB ~]#lvcreate -n lv_mysqlsoft_57 -L5G vg_mysqlsoft
Logical volume "lv_mysqlsoft_57" created
[root@LHRDB ~]# lvs
LV????????????? VG?????????? Attr?????? LSize? Pool Origin Data%? Move Log Cpy%Sync Convert
lv_mysqlsoft_57 vg_mysqlsoft -wi-a-----? 5.00g
Vol00?????????? vg_rootlhr?? -wi-ao---- 10.00g
Vol01?????????? vg_rootlhr?? -wi-ao----? 3.00g
Vol02?????????? vg_rootlhr?? -wi-ao----? 2.00g
Vol03?????????? vg_rootlhr?? -wi-ao----? 3.00g
[root@LHRDB ~]#mkfs.ext4 /dev/vg_mysqlsoft/lv_mysqlsoft_57
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.? Use tune2fs -c or -i to override.
[root@LHRDB ~]#mkdir -p /tmp/mysql5719
[root@LHRDB ~]#mkdir-p/var/lib/mysql57
[root@LHRDB ~]#mount /dev/vg_mysqlsoft/lv_mysqlsoft_57? /var/lib/mysql57/
[root@LHRDB ~]# df -h
Filesystem??????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00????????????? 9.9G? 4.9G? 4.6G? 52% /
tmpfs???????????????????????????????????? 2.0G?? 72K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01????????????? 3.0G? 680M? 2.2G? 24% /tmp
/dev/mapper/vg_rootlhr-Vol03????????????? 3.0G?? 69M? 2.8G?? 3% /home
.host:/?????????????????????????????????? 331G? 272G?? 59G? 83% /mnt/hgfs
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? 5.0G? 138M? 4.6G?? 3% /var/lib/mysql57
[root@LHRDB ~]#vi /etc/fstab
[root@LHRDB ~]#more /etc/fstab
# /etc/fstab
# Created by anaconda on Sat Jan 14 18:56:24 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_rootlhr-Vol00 /?????????????????????? ext4??? defaults??????? 1 1
UUID=fccf51c1-2d2f-4152-baac-99ead8cfbc1a /boot?????????????????? ext4??? defaults??????? 1 2
/dev/mapper/vg_rootlhr-Vol01 /tmp??????????????????? ext4??? defaults??????? 1 2
/dev/mapper/vg_rootlhr-Vol02 swap??????????????????? swap??? defaults??????? 0 0
tmpfs?????????????????? /dev/shm??????????????? tmpfs?? defaults,size=2G??????? 0 0
devpts????????????????? /dev/pts??????????????? devpts? gid=5,mode=620? 0 0
sysfs?????????????????? /sys??????????????????? sysfs?? defaults??????? 0 0
proc??????????????????? /proc?????????????????? proc??? defaults??????? 0 0
/dev/vg_rootlhr/Vol03 /home? ext4 defaults??????? 0 0
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? /var/lib/mysql57? ext4??? defaults? 0 0
1.7.2.1OS設(shè)置
關(guān)閉iptables防火墻:
臨時關(guān)閉:service iptables stop
永久關(guān)閉:chkconfig iptables off
關(guān)閉selinux
vi /etc/sysconfig/selinux
將SELINUX修改為DISABLED沿量,即SELINUX=DISABLED
1.7.3上傳文件并校驗MD5值
[root@LHRDB ~]# cd /tmp/mysql5719/
[root@LHRDB mysql5719]# ll
total 625640
-rw-r--r--. 1 root root 640650826 Aug 23 10:48 mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
[root@LHRDB mysql5719]#md5sum mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
dbe7e5e820377c29d8681005065e5728mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
和官網(wǎng)的MD5保持一致,說明安裝文件的下載和上傳過程沒有問題:
Compressed TAR Archive
5.7.19
611.0M
Download
(mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz)
MD5:dbe7e5e820377c29d8681005065e5728|Signature
1.7.4安裝
[root@LHRDB mysql5719]#tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /var/lib/mysql57/
mysql-5.7.19-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-5.7.19-linux-glibc2.12-x86_64/bin/myisamchk
mysql-5.7.19-linux-glibc2.12-x86_64/bin/myisamlog
mysql-5.7.19-linux-glibc2.12-x86_64/bin/myisampack
mysql-5.7.19-linux-glibc2.12-x86_64/bin/mysql
mysql-5.7.19-linux-glibc2.12-x86_64/bin/mysql_client_test_embedded
mysql-5.7.19-linux-glibc2.12-x86_64/bin/mysql_config_editor
mysql-5.7.19-linux-glibc2.12-x86_64/bin/mysql_embedded
mysql-5.7.19-linux-glibc2.12-x86_64/bin/mysql_install_db
mysql-5.7.19-linux-glibc2.12-x86_64/bin/mysql_plugin
冤荆。朴则。。钓简。乌妒。。涌庭。 省略部分芥被。。坐榆。。冗茸。席镀。。夏漱。
mysql-5.7.19-linux-glibc2.12-x86_64/lib/libmysqlclient.so.20
mysql-5.7.19-linux-glibc2.12-x86_64/lib/libmysqlclient.so.20.3.6
mysql-5.7.19-linux-glibc2.12-x86_64/share/install_rewriter.sql
mysql-5.7.19-linux-glibc2.12-x86_64/share/uninstall_rewriter.sql
mysql-5.7.19-linux-glibc2.12-x86_64/support-files/magic
mysql-5.7.19-linux-glibc2.12-x86_64/support-files/mysql.server
mysql-5.7.19-linux-glibc2.12-x86_64/docs/INFO_BIN
mysql-5.7.19-linux-glibc2.12-x86_64/docs/INFO_SRC
[root@LHRDB mysql5719]# df -h
Filesystem??????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00????????????? 9.9G? 4.9G? 4.6G? 52% /
tmpfs???????????????????????????????????? 2.0G?? 72K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01????????????? 3.0G? 680M? 2.2G? 24% /tmp
/dev/mapper/vg_rootlhr-Vol03????????????? 3.0G?? 69M? 2.8G?? 3% /home
.host:/?????????????????????????????????? 331G? 272G?? 59G? 83% /mnt/hgfs
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? 5.0G? 2.6G? 2.2G? 55% /var/lib/mysql57
1.7.5重命名安裝后的文件夾
[root@LHRDB ~]# cd /var/lib/mysql57/
[root@LHRDB mysql57]# ll
total 20
drwx------. 2 root root 16384 Aug 23 13:21 lost+found
drwxr-xr-x. 9 root root? 4096 Aug 23 13:28 mysql-5.7.19-linux-glibc2.12-x86_64
[root@LHRDB mysql57]#mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql5719
[root@LHRDB mysql57]# ll
total 20
drwx------. 2 root root 16384 Aug 23 13:21 lost+found
drwxr-xr-x. 9 root root? 4096 Aug 23 13:28 mysql5719
[root@LHRDB mysql57]#
也可以使用ln連接:
ln –smysql-5.7.19-linux-glibc2.12-x86_64mysql5719
1.7.6新建數(shù)據(jù)和日志文件目錄
[root@LHRDB mysql57]# mkdir -p /var/lib/mysql57/mysql5719/data
[root@LHRDB mysql57]# mkdir -p /var/lib/mysql57/mysql5719/log
1.7.7用戶和組設(shè)置
groupadd mysql????? ##添加一個mysql組
useradd -r -g mysql mysql??? ##添加一個用戶
useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql#新建msyql用戶禁止登錄shell
[root@LHRDB ~]# groupadd mysql
groupadd: group 'mysql' already exists
[root@LHRDB ~]# useradd -r -g mysql mysql
useradd: user 'mysql' already exists
說明本身就有mysql用戶和組豪诲。
1.7.8改變目錄屬有者
[root@LHRDB mysql57]# chown –R mysql.mysql /var/lib/mysql57
chown: invalid user: `\226R'
[root@LHRDB mysql57]# cd ..
[root@LHRDB lib]#chown –R mysql.mysql /var/lib/mysql57
1.7.9初始化MySQL
注意:MySQL5.7.6之后的版本初始化數(shù)據(jù)庫不再使用mysql_install_db,但是在MySQL 5.7.19里依然保留著這個文件挂绰。
官網(wǎng):https://dev.mysql.com/doc/refman/5.7/en/mysql-install-db.html
mysql_install_dbis deprecated as of MySQL 5.7.6 because its functionality has been integrated intomysqld, the MySQL server. To initialize a MySQL installation, invokemysqldwith the--initializeor--initialize-insecureoption. For more information, seeSection2.10.1.1, “Initializing the Data Directory Manually Using mysqld”.mysql_install_dbwill be removed in a future MySQL release.
[root@LHRDB mysql5719]# ll
total 60
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:27 bin
-rw-r--r--.? 1 mysql mysql 17987 Jun 22 22:13 COPYING
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:35 data
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:28 docs
drwxr-xr-x.? 3 mysql mysql? 4096 Aug 23 13:27 include
drwxr-xr-x.? 5 mysql mysql? 4096 Aug 23 13:28 lib
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:35 log
drwxr-xr-x.? 4 mysql mysql? 4096 Aug 23 13:27 man
-rw-r--r--.? 1 mysql mysql? 2478 Jun 22 22:13 README
drwxr-xr-x. 28 mysql mysql? 4096 Aug 23 13:28 share
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:28 support-files
[root@LHRDB mysql5719]#./bin/mysqld --initialize --user=mysql --basedir=/var/lib/mysql57/mysql5719? --datadir=/var/lib/mysql57/mysql5719/data
2017-08-23T05:45:58.820448Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-23T05:45:59.123446Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-08-23T05:45:59.197904Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-23T05:45:59.273227Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 571ab53c-87c6-11e7-ab76-000c291823c2.
2017-08-23T05:45:59.276384Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-08-23T05:45:59.277461Z 1 [Note] A temporary password is generated for root@localhost:k;A3Dktywkyj
[root@LHRDB mysql5719]#
這里生成的臨時密碼為:k;A3Dktywkyj
該過程會在data目錄下生成默認數(shù)據(jù)庫:
[root@LHRDB mysql5719]# cd data
[root@LHRDB data]# ll
total 110620
-rw-r-----. 1 mysql mysql?????? 56 Aug 23 13:45 auto.cnf
-rw-r-----. 1 mysql mysql????? 420 Aug 23 13:46 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Aug 23 13:46 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Aug 23 13:46 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Aug 23 13:45 ib_logfile1
drwxr-x---. 2 mysql mysql???? 4096 Aug 23 13:45 mysql
drwxr-x---. 2 mysql mysql???? 4096 Aug 23 13:45 performance_schema
drwxr-x---. 2 mysql mysql??? 12288 Aug 23 13:46 sys
[root@LHRDB data]# du -sh .
122M??? .
1.7.10生成秘鑰
創(chuàng)建SSL和RSA文件屎篱,關(guān)于這部分更多請參考:https://dev.mysql.com/doc/refman/5.7/en/mysql-ssl-rsa-setup.html。也可以不執(zhí)行這個步驟葵蒂。
[root@LHRDB mysql5719]#./bin/mysql_ssl_rsa_setup --datadir=/var/lib/mysql57/mysql5719/data
Generating a 2048 bit RSA private key
................................................................................................................+++
............................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
......................................+++
.................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
........................+++
.................................................................+++
writing new private key to 'client-key.pem'
-----
1.7.11配置/etc/my.cnf
生產(chǎn)庫上根據(jù)需要配置更多參數(shù):
[root@LHRDB support-files]# more /etc/my.cnf
[client]
port=3306
socket=/var/lib/mysql57/mysql.sock
[mysqld]
basedir=/var/lib/mysql57/mysql5719
datadir=/var/lib/mysql57/mysql5719/data
socket=/var/lib/mysql57/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/lib/mysql57/mysql5719/log/mysqld.log
pid-file=/var/lib/mysql57/mysql5719/data/mysqld.pid
1.7.12配置開機啟動文件
[root@LHRDB mysql5719]# cd support-files/
[root@LHRDB support-files]# ll
total 24
-rw-r--r--. 1 mysql mysql?? 773 Jun 22 22:13 magic
-rwxr-xr-x. 1 mysql mysql? 1061 Jun 22 22:54 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql?? 894 Jun 22 22:54 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Jun 22 22:54 mysql.server
[root@LHRDB support-files]#cp mysql.server /etc/init.d/mysql57
[root@LHRDB support-files]#chmod 755 /etc/init.d/mysql57
[root@LHRDB support-files]#chkconfig --add mysql57
[root@LHRDB support-files]#chkconfig mysql57on
[root@LHRDB support-files]#chkconfig --level 345 mysql57on
注意:這里的MySQL服務(wù)為mysql57
1.7.13啟動MySQL
[root@LHRDB support-files]# service mysql57start
Starting MySQL.2017-08-23T06:18:23.060126Z mysqld_safe error: log-error set to '/var/lib/mysql57/mysql5719/log/mysqld.log', however file don't exists. Create writable for user 'mysql'.
The server quit without updating PID file (/var/lib/mysql57/mysql5719/data/LHRDB.pid).[FAILED]
[root@LHRDB support-files]# cd /var/lib/mysql57/mysql5719/log/
[root@LHRDB log]# ll
total 0
[root@LHRDB log]# cd ..
[root@LHRDB mysql5719]# ll
total 60
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:27 bin
-rw-r--r--.? 1 mysql mysql 17987 Jun 22 22:13 COPYING
drwxr-xr-x.? 5 mysql mysql? 4096 Aug 23 13:46 data
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:28 docs
drwxr-xr-x.? 3 mysql mysql? 4096 Aug 23 13:27 include
drwxr-xr-x.? 5 mysql mysql? 4096 Aug 23 13:28 lib
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:35 log
drwxr-xr-x.? 4 mysql mysql? 4096 Aug 23 13:27 man
-rw-r--r--.? 1 mysql mysql? 2478 Jun 22 22:13 README
drwxr-xr-x. 28 mysql mysql? 4096 Aug 23 13:28 share
drwxr-xr-x.? 2 mysql mysql? 4096 Aug 23 13:28 support-files
[root@LHRDB mysql5719]#echo '' > /var/lib/mysql57/mysql5719/log/mysqld.log
[root@LHRDB mysql5719]#chown mysql.mysql /var/lib/mysql57/mysql5719/log/mysqld.log
[root@LHRDB mysql5719]#service mysql57start
Starting MySQL.[? OK? ]
[root@LHRDB mysql5719]# ps -ef|grep mysql
root???? 18194???? 1? 0 14:20 pts/1??? 00:00:00 /bin/sh /var/lib/mysql57/mysql5719/bin/mysqld_safe --datadir=/var/lib/mysql57/mysql5719/data --pid-file=/var/lib/mysql57/mysql5719/data/LHRDB.pid
mysql??? 18370 18194? 0 14:20 pts/1??? 00:00:00 /var/lib/mysql57/mysql5719/bin/mysqld --basedir=/var/lib/mysql57/mysql5719 --datadir=/var/lib/mysql57/mysql5719/data --plugin-dir=/var/lib/mysql57/mysql5719/lib/plugin --user=mysql --log-error=/var/lib/mysql57/mysql5719/log/mysqld.log --pid-file=/var/lib/mysql57/mysql5719/data/LHRDB.pid --socket=/var/lib/mysql57/mysql.sock
root???? 18407 13196? 0 14:21 pts/1??? 00:00:00 grep mysql
[root@LHRDB mysql5719]#
或者:
[root@LHRDB ~]# which mysqld_safe
/var/lib/mysql57/mysql5719/bin/mysqld_safe
[root@LHRDB ~]#mysqld_safe --user=mysql &
[1] 18674
[root@LHRDB ~]# 2017-08-23T06:40:04.996137Z mysqld_safe Logging to '/var/lib/mysql57/mysql5719/log/mysqld.log'.
2017-08-23T06:40:05.053483Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql57/mysql5719/data
1.7.14配置環(huán)境變量
編輯文件/etc/profile交播,在最后添加如下的內(nèi)容:
MYSQL_HOME=/var/lib/mysql57/mysql5719
PATH=$PATH:$MYSQL_HOME/bin
讓環(huán)境變量生效:source /etc/profile
1.7.15登錄MySQL并修改密碼
[root@LHRDB ~]# mysql -p
Enter password:---》臨時密碼為:k;A3Dktywkyj
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>set password=password('lhr');
Query OK, 0 rows affected, 1 warning (0.02 sec)
mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
| sys??????????????? |
+--------------------+
4 rows in set (0.04 sec)
修改密碼也可以用:update mysql.user set authentication_string=password('lhr') where user='root';
1.7.16設(shè)置遠程登錄
mysql>grant all privileges on *.* to root@'%' identified by 'lhr';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>select host,user from mysql.user;
+-----------+---------------+
| host????? | user????????? |
+-----------+---------------+
| %???????? | root????????? |
| localhost | mysql.session |
| localhost | mysql.sys???? |
| localhost | root????????? |
+-----------+---------------+
4 rows in set (0.00 sec)
[root@LHRDB ~]#mysql -uroot -plhr -h192.168.59.159
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
1.7.17Windows遠程登錄
在Windows下遠程登錄:
D:\Users\xiaomaimiao>mysql -uroot -plhr -h192.168.59.159
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
可能會出現(xiàn)下面的錯誤:
D:\Users\xiaomaimiao>mysql -uroot -plhr -h192.168.59.159
Warning: Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.59.159' (10060)
原因:主機192.168.59.159上的防火墻未關(guān)閉
解決辦法:關(guān)閉防火墻,以下2個命令都需要執(zhí)行:
chkconfig iptables off?? ---永久
service iptables stop??? ---臨時
1.7.18客戶端工具登錄
1.7.18.1Navicat for MySQL
1.7.18.2MySQLWorkbench
MySQL官方提供的工具践付,還是比較實用的:
該工具比較強大秦士,有很多的實用功能:
1.8MySQL 5.6安裝
1.8.1下載
1.8.2OS路徑設(shè)置
[root@LHRDB ~]# df -h
Filesystem??????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00????????????? 9.9G? 4.8G? 4.6G? 51% /
tmpfs???????????????????????????????????? 2.0G?? 72K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01????????????? 3.0G? 681M? 2.2G? 24% /tmp
/dev/mapper/vg_rootlhr-Vol03????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
.host:/?????????????????????????????????? 331G? 272G?? 59G? 83% /mnt/hgfs
[root@LHRDB ~]# vgs
VG?????????? #PV #LV #SN Attr?? VSize? VFree
vg_mysqlsoft?? 1?? 1?? 0 wz--n- 10.00g 5.00g
vg_rootlhr???? 2?? 4?? 0 wz--n- 19.80g 1.80g
[root@LHRDB ~]#lvcreate -n lv_mysqlsoft_56 -L 2G vg_mysqlsoft
Logical volume "lv_mysqlsoft_56" created
[root@LHRDB ~]#mkfs.ext4 /dev/vg_mysqlsoft/lv_mysqlsoft_56
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.? Use tune2fs -c or -i to override.
[root@LHRDB ~]# cd /usr/local/mysql
-bash: cd: /usr/local/mysql: No such file or directory
[root@LHRDB ~]# mkdir /usr/local/mysql56
[root@LHRDB ~]# chown mysql /usr/local/mysql56
[root@LHRDB ~]# mount /dev/vg_mysqlsoft/lv_mysqlsoft_56? /usr/local/mysql56/
[root@LHRDB ~]# df -h
Filesystem??????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00????????????? 9.9G? 4.8G? 4.6G? 51% /
tmpfs???????????????????????????????????? 2.0G?? 72K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01????????????? 3.0G? 681M? 2.2G? 24% /tmp
/dev/mapper/vg_rootlhr-Vol03????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
.host:/?????????????????????????????????? 331G? 272G?? 59G? 83% /mnt/hgfs
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56? 2.0G?? 67M? 1.9G?? 4% /usr/local/mysql56
1.8.3安裝MySQL 5.6
rpm的安裝方式請參考:
http://blog.itpub.net/26736162/viewspace-1349705/
http://blog.itpub.net/26736162/viewspace-1349787/
[root@LHRDB mysql56]#tar -zxvf /tmp/mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql56/
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/test-ATIS
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/test-select
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/crash-me
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/test-wisconsin
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/innotest1b
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/innotest2a
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/innotest1
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/test-create
mysql-5.6.37-linux-glibc2.12-x86_64/sql-bench/bench-count-distinct
。永高。隧土。。命爬。曹傀。。饲宛。皆愉。。。亥啦。省略炭剪。。翔脱。奴拦。。届吁。错妖。。疚沐。暂氯。。亮蛔。痴施。。
mysql-5.6.37-linux-glibc2.12-x86_64/mysql-test/t/events_restart-master.opt
mysql-5.6.37-linux-glibc2.12-x86_64/mysql-test/t/empty_table.test
mysql-5.6.37-linux-glibc2.12-x86_64/mysql-test/t/innodb_mrr-master.opt
mysql-5.6.37-linux-glibc2.12-x86_64/mysql-test/t/ssl_mode_no_ssl-master.opt
mysql-5.6.37-linux-glibc2.12-x86_64/mysql-test/valgrind.supp
mysql-5.6.37-linux-glibc2.12-x86_64/mysql-test/mysql-test-run.pl
[root@LHRDB mysql56]# mv mysql-5.6.37-linux-glibc2.12-x86_64 mysql5637
[root@LHRDB mysql56]# cd mysql5637/
[root@LHRDB mysql5637]# ll
total 68
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 bin
-rw-r--r--? 1 mysql mysql 17987 Jun? 3 01:42 COPYING
drwxr-xr-x? 3 mysql mysql? 4096 Aug 25 18:24 data
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 docs
drwxr-xr-x? 3 mysql mysql? 4096 Aug 25 18:24 include
drwxr-xr-x? 3 mysql mysql? 4096 Aug 25 18:24 lib
drwxr-xr-x? 4 mysql mysql? 4096 Aug 25 18:24 man
drwxr-xr-x 10 mysql mysql? 4096 Aug 25 18:24 mysql-test
-rw-r--r--? 1 mysql mysql? 2496 Jun? 3 01:42 README
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 scripts
drwxr-xr-x 28 mysql mysql? 4096 Aug 25 18:24 share
drwxr-xr-x? 4 mysql mysql? 4096 Aug 25 18:24 sql-bench
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 support-files
[root@LHRDB mysql5637]# mkdir log
[root@LHRDB mysql5637]# chown mysql.mysql log
[root@LHRDB mysql5637]# ll
total 72
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 bin
-rw-r--r--? 1 mysql mysql 17987 Jun? 3 01:42 COPYING
drwxr-xr-x? 3 mysql mysql? 4096 Aug 25 18:24 data
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 docs
drwxr-xr-x? 3 mysql mysql? 4096 Aug 25 18:24 include
drwxr-xr-x? 3 mysql mysql? 4096 Aug 25 18:24 lib
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:32 log
drwxr-xr-x? 4 mysql mysql? 4096 Aug 25 18:24 man
drwxr-xr-x 10 mysql mysql? 4096 Aug 25 18:24 mysql-test
-rw-r--r--? 1 mysql mysql? 2496 Jun? 3 01:42 README
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 scripts
drwxr-xr-x 28 mysql mysql? 4096 Aug 25 18:24 share
drwxr-xr-x? 4 mysql mysql? 4096 Aug 25 18:24 sql-bench
drwxr-xr-x? 2 mysql mysql? 4096 Aug 25 18:24 support-files
1.8.4初始化
[root@LHRDB mysql5637]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql56/mysql5637 --datadir=/usr/local/mysql56/mysql5637/data
Installing MySQL system tables...2017-08-25 18:37:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-25 18:37:13 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-08-25 18:37:13 0 [Note] /usr/local/mysql56/mysql5637/bin/mysqld (mysqld 5.6.37) starting as process 17757 ...
2017-08-25 18:37:13 17757 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-08-25 18:37:13 17757 [Note] InnoDB: The InnoDB memory heap is disabled
2017-08-25 18:37:13 17757 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-08-25 18:37:13 17757 [Note] InnoDB: Memory barrier is not used
2017-08-25 18:37:13 17757 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-08-25 18:37:13 17757 [Note] InnoDB: Using Linux native AIO
2017-08-25 18:37:13 17757 [Note] InnoDB: Using CPU crc32 instructions
2017-08-25 18:37:13 17757 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-08-25 18:37:13 17757 [Note] InnoDB: Completed initialization of buffer pool
2017-08-25 18:37:13 17757 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-08-25 18:37:13 17757 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-08-25 18:37:13 17757 [Note] InnoDB: Database physically writes the file full: wait...
2017-08-25 18:37:13 17757 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-08-25 18:37:13 17757 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-08-25 18:37:13 17757 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-08-25 18:37:13 17757 [Warning] InnoDB: New log files created, LSN=45781
2017-08-25 18:37:13 17757 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-08-25 18:37:13 17757 [Note] InnoDB: Doublewrite buffer created
2017-08-25 18:37:13 17757 [Note] InnoDB: 128 rollback segment(s) are active.
2017-08-25 18:37:13 17757 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-25 18:37:13 17757 [Note] InnoDB: Foreign key constraint system tables created
2017-08-25 18:37:13 17757 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-08-25 18:37:13 17757 [Note] InnoDB: Tablespace and datafile system tables created.
2017-08-25 18:37:13 17757 [Note] InnoDB: Waiting for purge to start
2017-08-25 18:37:13 17757 [Note] InnoDB: 5.6.37 started; log sequence number 0
2017-08-25 18:37:14 17757 [Note] Binlog end
2017-08-25 18:37:14 17757 [Note] InnoDB: FTS optimize thread exiting.
2017-08-25 18:37:14 17757 [Note] InnoDB: Starting shutdown...
2017-08-25 18:37:15 17757 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2017-08-25 18:37:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-25 18:37:15 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-08-25 18:37:15 0 [Note] /usr/local/mysql56/mysql5637/bin/mysqld (mysqld 5.6.37) starting as process 17779 ...
2017-08-25 18:37:15 17779 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-08-25 18:37:15 17779 [Note] InnoDB: The InnoDB memory heap is disabled
2017-08-25 18:37:15 17779 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-08-25 18:37:15 17779 [Note] InnoDB: Memory barrier is not used
2017-08-25 18:37:15 17779 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-08-25 18:37:15 17779 [Note] InnoDB: Using Linux native AIO
2017-08-25 18:37:15 17779 [Note] InnoDB: Using CPU crc32 instructions
2017-08-25 18:37:15 17779 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-08-25 18:37:15 17779 [Note] InnoDB: Completed initialization of buffer pool
2017-08-25 18:37:15 17779 [Note] InnoDB: Highest supported file format is Barracuda.
2017-08-25 18:37:15 17779 [Note] InnoDB: 128 rollback segment(s) are active.
2017-08-25 18:37:15 17779 [Note] InnoDB: Waiting for purge to start
2017-08-25 18:37:15 17779 [Note] InnoDB: 5.6.37 started; log sequence number 1625977
2017-08-25 18:37:15 17779 [Note] Binlog end
2017-08-25 18:37:15 17779 [Note] InnoDB: FTS optimize thread exiting.
2017-08-25 18:37:15 17779 [Note] InnoDB: Starting shutdown...
2017-08-25 18:37:17 17779 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql56/mysql5637/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql56/mysql5637/bin/mysqladmin -u root -h LHRDB password 'new-password'
Alternatively you can run:
/usr/local/mysql56/mysql5637/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.? This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql56/mysql5637/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as/usr/local/mysql56/mysql5637/my.cnfand
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@LHRDB mysql5637]# cd data
[root@LHRDB data]# ll
total 110604
-rw-rw---- 1 mysql mysql 12582912 Aug 25 18:37 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Aug 25 18:37 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Aug 25 18:37 ib_logfile1
drwx------ 2 mysql mysql???? 4096 Aug 25 18:37 mysql
drwx------ 2 mysql mysql???? 4096 Aug 25 18:37 performance_schema
drwxr-xr-x 2 mysql mysql???? 4096 Aug 25 18:24 test
1.8.5配置參數(shù)文件并啟動MySQL
[root@LHRDB mysql5637]# more ./support-files/my.cnf
[mysqld]
basedir=/usr/local/mysql56/mysql5637
datadir=/usr/local/mysql56/mysql5637/data
socket=/usr/local/mysql56/mysql5637/mysql.sock
log-error=/usr/local/mysql56/mysql5637/log/mysqld.log
user=mysql
port=3307
[root@LHRDB mysql5637]# echo '' > /usr/local/mysql56/mysql5637/log/mysqld.log
[root@LHRDB mysql5637]#./bin/mysqld_safe --defaults-file=./support-files/my.cnf &
[2] 13852
[root@LHRDB mysql5637]# 170827 17:52:15 mysqld_safe Logging to '/usr/local/mysql56/mysql5637/log/mysqld.log'.
170827 17:52:15 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql56/mysql5637/data
[root@LHRDB mysql5637]# ps -ef|grep mysql
root???? 13195 13170? 0 17:35 pts/0??? 00:00:00 tail -f /var/lib/mysql57/mysql5719/log/mysqld_multi.log
root???? 13671 13198? 0 17:45 pts/1??? 00:00:00 /bin/sh ./bin/mysqld_safe --defaults-file=./support-files/my.cnf
mysql??? 13811 13671? 0 17:45 pts/1??? 00:00:00 /usr/local/mysql55/mysql5557/bin/mysqld --defaults-file=./support-files/my.cnf --basedir=/usr/local/mysql55/mysql5557 --datadir=/usr/local/mysql55/mysql5557/data --plugin-dir=/usr/local/mysql55/mysql5557/lib/plugin --user=mysql --log-error=/usr/local/mysql55/mysql5557/log/mysqld.log --pid-file=LHRDB.pid --socket=/usr/local/mysql55/mysql5557/mysql.sock --port=3308
root???? 13852 13198? 0 17:52 pts/1??? 00:00:00 /bin/sh ./bin/mysqld_safe --defaults-file=./support-files/my.cnf
mysql??? 13990 13852 10 17:52 pts/1??? 00:00:00 /usr/local/mysql56/mysql5637/bin/mysqld --defaults-file=./support-files/my.cnf --basedir=/usr/local/mysql56/mysql5637 --datadir=/usr/local/mysql56/mysql5637/data --plugin-dir=/usr/local/mysql56/mysql5637/lib/plugin --user=mysql --log-error=/usr/local/mysql56/mysql5637/log/mysqld.log --pid-file=LHRDB.pid --socket=/usr/local/mysql56/mysql5637/mysql.sock --port=3307
root???? 14015 13198? 0 17:52 pts/1??? 00:00:00 grep mysql
1.8.6修改密碼
MySQL 5.6的二進制安裝默認密碼為空究流。
set password=password('lhr');
[root@LHRDB mysql5719]#mysql -uroot? --socket=/usr/local/mysql56/mysql5637/mysql.sock -p
Enter password:
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>set password=password("lhr");
Query OK, 0 rows affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
| test?????????????? |
+--------------------+
4 rows in set (0.00 sec)
1.8.7設(shè)置遠程登錄
mysql> select host,user from mysql.user;
+-----------+------+
| host????? | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1?????? | root |
| lhrdb???? |????? |
| lhrdb???? | root |
| localhost |????? |
| localhost | root |
+-----------+------+
6 rows in set (0.00 sec)
mysql>grant all privileges on *.* to root@'%' identified by 'lhr';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>select host,user from mysql.user;
+-----------+------+
| host????? | user |
+-----------+------+
| %???????? | root |
| 127.0.0.1 | root |
| ::1?????? | root |
| lhrdb???? |????? |
| lhrdb???? | root |
| localhost |????? |
| localhost | root |
+-----------+------+
1.8.8遠程登錄
D:\Users\xiaomaimiao>mysql -uroot -plhr -h192.168.59.159 -P 3307
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
1.9MySQL 5.5安裝
1.9.1下載
1.9.2OS路徑設(shè)置
[root@LHRDB ~]#lvcreate -n lv_mysqlsoft_55 -L 2G vg_mysqlsoft
Logical volume "lv_mysqlsoft_55" created
[root@LHRDB ~]#mkfs.ext4 /dev/vg_mysqlsoft/lv_mysqlsoft_55
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.? Use tune2fs -c or -i to override.
[root@LHRDB ~]# mkdir /usr/local/mysql55
[root@LHRDB ~]# chown mysql /usr/local/mysql55
[root@LHRDB ~]# mount /dev/vg_mysqlsoft/lv_mysqlsoft_55? /usr/local/mysql55/
[root@LHRDB ~]# df -h
Filesystem??????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00????????????? 9.9G? 4.8G? 4.6G? 52% /
tmpfs???????????????????????????????????? 2.0G?? 68K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01????????????? 3.0G? 1.1G? 1.8G? 40% /tmp
/dev/mapper/vg_rootlhr-Vol03????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
.host:/?????????????????????????????????? 331G? 272G?? 59G? 83% /mnt/hgfs
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56? 2.0G?? 67M? 1.9G?? 4% /usr/local/mysql56
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55? 2.0G?? 67M? 1.9G?? 4% /usr/local/mysql55
1.9.3安裝MySQL 5.5
[root@LHRDB mysql56]#tar -zxvf /tmp/mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql55
mysql-5.5.57-linux-glibc2.12-x86_64/scripts/mysql_install_db
mysql-5.5.57-linux-glibc2.12-x86_64/INSTALL-BINARY
mysql-5.5.57-linux-glibc2.12-x86_64/share/slovak/errmsg.sys
mysql-5.5.57-linux-glibc2.12-x86_64/share/norwegian/errmsg.sys
mysql-5.5.57-linux-glibc2.12-x86_64/share/fill_help_tables.sql
mysql-5.5.57-linux-glibc2.12-x86_64/share/spanish/errmsg.sys
mysql-5.5.57-linux-glibc2.12-x86_64/share/czech/errmsg.sys
mysql-5.5.57-linux-glibc2.12-x86_64/share/dutch/errmsg.sys
辣吃。。芬探。神得。。偷仿。哩簿。。酝静。节榜。。形入。省略全跨。。亿遂。浓若。。蛇数。挪钓。。耳舅。碌上。倚评。。馏予。天梧。
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/t/secure_file_priv_null-master.opt
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/t/secure_file_priv_warnings_win.test
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/t/secure_file_priv_error.test
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/t/secure_file_priv_null.test
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/t/secure_file_priv_warnings.test
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/r/secure_file_priv_warnings.result
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/r/secure_file_priv_error.result
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/r/secure_file_priv_warnings_win.result
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/r/secure_file_priv_null.result
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/r/cert_verify.result
mysql-5.5.57-linux-glibc2.12-x86_64/mysql-test/suite/auth_sec/r/secure_file_priv_warnings_not_win.result
[root@LHRDB tmp]# cd /usr/local/mysql55
[root@LHRDB mysql55]# ll
total 4
drwxr-xr-x 13 root root 4096 Aug 27 17:07 mysql-5.5.57-linux-glibc2.12-x86_64
[root@LHRDB mysql55]#
[root@LHRDB mysql55]#mv mysql-5.5.57-linux-glibc2.12-x86_64 mysql5557
[root@LHRDB mysql55]# cd mysql5557/
[root@LHRDB mysql5557]# ll
total 72
drwxr-xr-x? 2 root root?? 4096 Aug 27 17:07 bin
-rw-r--r--? 1 7161 31415 17987 Jun? 5 14:38 COPYING
drwxr-xr-x? 3 root root?? 4096 Aug 27 17:07 data
drwxr-xr-x? 2 root root?? 4096 Aug 27 17:07 docs
drwxr-xr-x? 3 root root?? 4096 Aug 27 17:07 include
-rw-r--r--? 1 7161 31415?? 301 Jun? 5 14:38 INSTALL-BINARY
drwxr-xr-x? 3 root root?? 4096 Aug 27 17:07 lib
drwxr-xr-x? 4 root root?? 4096 Aug 27 17:07 man
drwxr-xr-x 10 root root?? 4096 Aug 27 17:07 mysql-test
-rw-r--r--? 1 7161 31415? 2496 Jun? 5 14:38 README
drwxr-xr-x? 2 root root?? 4096 Aug 27 17:07 scripts
drwxr-xr-x 27 root root?? 4096 Aug 27 17:07 share
drwxr-xr-x? 4 root root?? 4096 Aug 27 17:07 sql-bench
drwxr-xr-x? 2 root root?? 4096 Aug 27 17:07 support-files
[root@LHRDB mysql5557]# mkdir log
[root@LHRDB mysql5557]# cd ..
[root@LHRDB mysql55]# chown mysql.mysql .
[root@LHRDB mysql55]# chown -R mysql.mysql .
1.9.4初始化
[root@LHRDB mysql5557]# ll
total 76
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 bin
-rw-r--r--? 1 mysql mysql 17987 Jun? 5 14:38 COPYING
drwxr-xr-x? 3 mysql mysql? 4096 Aug 27 17:07 data
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 docs
drwxr-xr-x? 3 mysql mysql? 4096 Aug 27 17:07 include
-rw-r--r--? 1 mysql mysql?? 301 Jun? 5 14:38 INSTALL-BINARY
drwxr-xr-x? 3 mysql mysql? 4096 Aug 27 17:07 lib
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:10 log
drwxr-xr-x? 4 mysql mysql? 4096 Aug 27 17:07 man
drwxr-xr-x 10 mysql mysql? 4096 Aug 27 17:07 mysql-test
-rw-r--r--? 1 mysql mysql? 2496 Jun? 5 14:38 README
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 scripts
drwxr-xr-x 27 mysql mysql? 4096 Aug 27 17:07 share
drwxr-xr-x? 4 mysql mysql? 4096 Aug 27 17:07 sql-bench
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 support-files
[root@LHRDB mysql5557]# pwd
/usr/local/mysql55/mysql5557
[root@LHRDB mysql5557]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql55/mysql5557 --datadir=/usr/local/mysql55/mysql5557/data
Installing MySQL system tables...
170827 17:12:09 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170827 17:12:09 [Note] /usr/local/mysql55/mysql5557/bin/mysqld (mysqld 5.5.57) starting as process 19995 ...
OK
Filling help tables...
170827 17:12:10 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170827 17:12:10 [Note] /usr/local/mysql55/mysql5557/bin/mysqld (mysqld 5.5.57) starting as process 20002 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql55/mysql5557/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql55/mysql5557/bin/mysqladmin -u root -h LHRDB password 'new-password'
Alternatively you can run:
/usr/local/mysql55/mysql5557/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.? This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql55/mysql5557 ; /usr/local/mysql55/mysql5557/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql55/mysql5557/mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
[root@LHRDB mysql5557]# ll
total 76
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 bin
-rw-r--r--? 1 mysql mysql 17987 Jun? 5 14:38 COPYING
drwxr-xr-x? 5 mysql mysql? 4096 Aug 27 17:12 data
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 docs
drwxr-xr-x? 3 mysql mysql? 4096 Aug 27 17:07 include
-rw-r--r--? 1 mysql mysql?? 301 Jun? 5 14:38 INSTALL-BINARY
drwxr-xr-x? 3 mysql mysql? 4096 Aug 27 17:07 lib
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:10 log
drwxr-xr-x? 4 mysql mysql? 4096 Aug 27 17:07 man
drwxr-xr-x 10 mysql mysql? 4096 Aug 27 17:07 mysql-test
-rw-r--r--? 1 mysql mysql? 2496 Jun? 5 14:38 README
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 scripts
drwxr-xr-x 27 mysql mysql? 4096 Aug 27 17:07 share
drwxr-xr-x? 4 mysql mysql? 4096 Aug 27 17:07 sql-bench
drwxr-xr-x? 2 mysql mysql? 4096 Aug 27 17:07 support-files
[root@LHRDB mysql5557]# cd data/
[root@LHRDB data]# ll
total 12
drwx------ 2 mysql root? 4096 Aug 27 17:12 mysql
drwx------ 2 mysql mysql 4096 Aug 27 17:12 performance_schema
drwxr-xr-x 2 mysql mysql 4096 Aug 27 17:07 test
[root@LHRDB data]# df -h
Filesystem??????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00????????????? 9.9G? 4.6G? 4.9G? 49% /
tmpfs???????????????????????????????????? 2.0G?? 68K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01????????????? 3.0G? 1.2G? 1.7G? 42% /tmp
/dev/mapper/vg_rootlhr-Vol03????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
.host:/?????????????????????????????????? 331G? 273G?? 58G? 83% /mnt/hgfs
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56? 2.0G? 1.4G? 575M? 70% /usr/local/mysql56
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55? 2.0G? 848M? 1.1G? 45% /usr/local/mysql55
1.9.5配置參數(shù)文件并啟動MySQL
[root@LHRDB support-files]# more my.cnf
[mysqld]
basedir=/usr/local/mysql55/mysql5557
datadir=/usr/local/mysql55/mysql5557/data
socket=/usr/local/mysql55/mysql5557/mysql.sock
log-error=/usr/local/mysql55/mysql5557/log/mysqld.log
user=mysql
port=3308
[root@LHRDB support-files]# cd ..
[root@LHRDB mysql5557]#
[root@LHRDB mysql5557]#echo '' > /usr/local/mysql55/mysql5557/log/mysqld.log
[root@LHRDB mysql5557]#
[root@LHRDB mysql5557]#./bin/mysqld_safe --defaults-file=./support-files/my.cnf &
[1] 13671
[root@LHRDB mysql5557]# 170827 17:45:54 mysqld_safe Logging to '/usr/local/mysql55/mysql5557/log/mysqld.log'.
170827 17:45:54 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql55/mysql5557/data
[root@LHRDB mysql5557]# ps -ef|grep mysql
root???? 13195 13170? 0 17:35 pts/0??? 00:00:00 tail -f /var/lib/mysql57/mysql5719/log/mysqld_multi.log
root???? 13671 13198? 0 17:45 pts/1??? 00:00:00 /bin/sh ./bin/mysqld_safe --defaults-file=./support-files/my.cnf
mysql??? 13811 13671? 0 17:45 pts/1??? 00:00:00 /usr/local/mysql55/mysql5557/bin/mysqld --defaults-file=./support-files/my.cnf --basedir=/usr/local/mysql55/mysql5557 --datadir=/usr/local/mysql55/mysql5557/data --plugin-dir=/usr/local/mysql55/mysql5557/lib/plugin --user=mysql --log-error=/usr/local/mysql55/mysql5557/log/mysqld.log --pid-file=LHRDB.pid --socket=/usr/local/mysql55/mysql5557/mysql.sock --port=3308
root???? 13830 13198? 0 17:45 pts/1??? 00:00:00 grep mysql
1.9.6修改密碼
MySQL 5.5的二進制安裝默認密碼為空。
set password=password('lhr');
[root@LHRDB mysql5719]#mysql -uroot? --socket=/usr/local/mysql55/mysql5557/mysql.sock -p
Enter password:
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>set password=password("lhr");
Query OK, 0 rows affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
| test?????????????? |
+--------------------+
4 rows in set (0.00 sec)
1.9.7設(shè)置遠程登錄
mysql> select host,user from mysql.user;
+-----------+------+
| host????? | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1?????? | root |
| lhrdb???? |????? |
| lhrdb???? | root |
| localhost |????? |
| localhost | root |
+-----------+------+
6 rows in set (0.00 sec)
mysql>grant all privileges on *.* to root@'%' identified by 'lhr';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>select host,user from mysql.user;
+-----------+------+
| host????? | user |
+-----------+------+
| %???????? | root |
| 127.0.0.1 | root |
| ::1?????? | root |
| lhrdb???? |????? |
| lhrdb???? | root |
| localhost |????? |
| localhost | root |
+-----------+------+
1.9.8遠程登錄
D:\Users\xiaomaimiao>mysql -uroot -plhr -h192.168.59.159 -P 3308
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.57 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
1.10配置多版本霞丧、多實例開機自啟動
1.10.1配置/etc/my.cnf
[root@LHRDB support-files]# more /etc/my.cnf
[mysqld_multi]
mysqld=mysqld_safe
mysqladmin=/var/lib/mysql57/mysql5719/bin/mysqladmin
log=/var/lib/mysql57/mysql5719/log/mysqld_multi.log
user=root
pass=lhr
[client]
port=3306
socket=/var/lib/mysql57/mysql5719/mysql.sock
user=root
host=localhost
password=lhr
[mysqld]
basedir=/var/lib/mysql57/mysql5719
datadir=/var/lib/mysql57/mysql5719/data
socket=/var/lib/mysql57/mysql5719/mysql.sock
log-error=/var/lib/mysql57/mysql5719/log/mysqld.log
user=mysql
port=3306
[mysqld56]
basedir=/usr/local/mysql56/mysql5637
datadir=/usr/local/mysql56/mysql5637/data
socket=/usr/local/mysql56/mysql5637/mysql.sock
log-error=/usr/local/mysql56/mysql5637/log/mysqld.log
user=mysql
port=3307
[mysqld55]
basedir=/usr/local/mysql55/mysql5557
datadir=/usr/local/mysql55/mysql5557/data
socket=/usr/local/mysql55/mysql5557/mysql.sock
log-error=/usr/local/mysql55/mysql5557/log/mysqld.log
user=mysql
port=3308
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/lib/mysql57/mysql5719/log/mysqld.log
#pid-file=/var/lib/mysql57/mysql5719/data/mysqld.pid
1.10.2配置開機啟動
[root@LHRDB mysql5719]# cd support-files/
[root@LHRDB support-files]# ll
total 24
-rw-r--r--. 1 mysql mysql?? 773 Jun 22 22:13 magic
-rwxr-xr-x. 1 mysql mysql? 1061 Jun 22 22:54 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql?? 894 Jun 22 22:54 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Jun 22 22:54 mysql.server
[root@LHRDB support-files]# cp mysqld_multi.server /etc/init.d/mysqld_multi
[root@LHRDB support-files]# chmod 755 /etc/init.d/mysqld_multi
[root@LHRDB support-files]# chkconfig --add mysqld_multi
[root@LHRDB support-files]# chkconfig mysqld_multi on
[root@LHRDB support-files]# chkconfig --level 345 mysqld_multi on
注意:這里的MySQL服務(wù)為mysqld_multi
編輯文件:/etc/init.d/mysqld_multi呢岗,修改如下3行的參數(shù)值:
. /etc/profile
basedir=/var/lib/mysql57/mysql5719
bindir=/var/lib/mysql57/mysql5719/bin
由于采用了mysqld_multi來統(tǒng)一管理MySQL的實例,所以蛹尝,去掉mysql 5.7的開機啟動后豫。
chkconfig mysql57off
[root@LHRDB init.d]# chkconfig mysql57 off
重啟機器,試試效果:
[root@LHRDB init.d]# reboot
[root@LHRDB init.d]#
Broadcast message from root@LHRDB
(/dev/pts/1) at 18:27 ...
The system is going down for reboot NOW!
重啟之后:
[root@LHRDB ~]# ps -ef|grep mysql
root???? 12338???? 1? 0 20:19 ???????? 00:00:00 /bin/sh /var/lib/mysql57/mysql5719/bin/mysqld_safe --basedir=/var/lib/mysql57/mysql5719 --datadir=/var/lib/mysql57/mysql5719/data --socket=/var/lib/mysql57/mysql5719/mysql.sock --log-error=/var/lib/mysql57/mysql5719/log/mysqld.log --user=mysql --port=3306
root???? 12401???? 1? 0 20:19 ???????? 00:00:00 /bin/sh /var/lib/mysql57/mysql5719/bin/mysqld_safe --basedir=/usr/local/mysql56/mysql5637 --datadir=/usr/local/mysql56/mysql5637/data --socket=/usr/local/mysql56/mysql5637/mysql.sock --log-error=/usr/local/mysql56/mysql5637/log/mysqld.log --user=mysql --port=3307
root???? 12471???? 1? 0 20:19 ???????? 00:00:00 /bin/sh /var/lib/mysql57/mysql5719/bin/mysqld_safe --basedir=/usr/local/mysql55/mysql5557 --datadir=/usr/local/mysql55/mysql5557/data --socket=/usr/local/mysql55/mysql5557/mysql.sock --log-error=/usr/local/mysql55/mysql5557/log/mysqld.log --user=mysql --port=3308 --symbolic-links=0
mysql??? 12792 12471? 0 20:19 ???????? 00:00:00 /usr/local/mysql55/mysql5557/bin/mysqld --basedir=/usr/local/mysql55/mysql5557 --datadir=/usr/local/mysql55/mysql5557/data --plugin-dir=/usr/local/mysql55/mysql5557/lib/plugin --user=mysql --symbolic-links=0 --log-error=/usr/local/mysql55/mysql5557/log/mysqld.log --pid-file=LHRDB.pid --socket=/usr/local/mysql55/mysql5557/mysql.sock --port=3308
mysql??? 12822 12338? 0 20:19 ???????? 00:00:00 /var/lib/mysql57/mysql5719/bin/mysqld --basedir=/var/lib/mysql57/mysql5719 --datadir=/var/lib/mysql57/mysql5719/data --plugin-dir=/var/lib/mysql57/mysql5719/lib/plugin --user=mysql --log-error=/var/lib/mysql57/mysql5719/log/mysqld.log --pid-file=LHRDB.pid --socket=/var/lib/mysql57/mysql5719/mysql.sock --port=3306
mysql??? 12885 12401? 0 20:19 ???????? 00:00:00 /usr/local/mysql56/mysql5637/bin/mysqld --basedir=/usr/local/mysql56/mysql5637 --datadir=/usr/local/mysql56/mysql5637/data --plugin-dir=/usr/local/mysql56/mysql5637/lib/plugin --user=mysql --log-error=/usr/local/mysql56/mysql5637/log/mysqld.log --pid-file=LHRDB.pid --socket=/usr/local/mysql56/mysql5637/mysql.sock --port=3307
root???? 13205 13179? 0 20:20 pts/0??? 00:00:00 grep mysql
[root@LHRDB ~]#mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld57 is running
MySQL server from group: mysqld56 is running
MySQL server from group: mysqld55 is running
[root@LHRDB ~]#netstat -lntp | grep mysqld
tcp??????? 0????? 0 0.0.0.0:3308??????????????? 0.0.0.0:*?????????????????? LISTEN????? 12792/mysqld
tcp??????? 0????? 0 :::3307???????????????????? :::*??????????????????????? LISTEN????? 12885/mysqld
tcp??????? 0????? 0 :::3306???????????????????? :::*??????????????????????? LISTEN????? 12822/mysqld
1.10.3mysqld_multi命令
啟動全部實例:mysqld_multi start
查看全部實例狀態(tài):mysqld_multi report
啟動單個實例:mysqld_multi start 3306
停止單個實例:mysqld_multi stop 3306
查看單個實例狀態(tài):mysqld_multi report 3306
官網(wǎng)地址:https://dev.mysql.com/doc/refman/5.7/en/mysqld-multi.html
1.11源碼編譯安裝MySQL 5.7
源碼編譯安裝的更多內(nèi)容:http://blog.itpub.net/26736162/viewspace-2144212/
1.11.1下載源碼包
地址:https://dev.mysql.com/downloads/mysql/
說明:這里有兩個包突那,在5.7以后挫酿,必須要有boost這個包
1.11.2增加用戶
groupadd mysql
useradd -r -g mysql mysql
其中-r表示用戶是系統(tǒng)用戶,不可登錄系統(tǒng)愕难。
1.11.3創(chuàng)建要安裝的目錄
[root@LHRDB ~]# df -h
Filesystem??????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00????????????? 9.9G? 4.6G? 4.9G? 49% /
tmpfs???????????????????????????????????? 2.0G?? 76K? 2.0G?? 1% /dev/shm
/dev/sda1???????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01????????????? 3.0G? 1.8G? 1.1G? 64% /tmp
/dev/mapper/vg_rootlhr-Vol03????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56? 2.0G? 1.4G? 575M? 70% /usr/local/mysql56
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55? 2.0G? 848M? 1.1G? 45% /usr/local/mysql55
.host:/?????????????????????????????????? 331G? 273G?? 58G? 83% /mnt/hgfs
/dev/sr0????????????????????????????????? 3.6G? 3.6G???? 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/sr0????????????????????????????????? 3.6G? 3.6G???? 0 100% /media/lhr/cdrom
[root@LHRDB ~]# vgs
VG?????????? #PV #LV #SN Attr?? VSize? VFree
vg_mysqlsoft?? 1?? 3?? 0 wz--n- 10.00g 1020.00m
vg_rootlhr???? 2?? 4?? 0 wz--n- 19.80g??? 1.80g
[root@LHRDB ~]# pvs
PV???????? VG?????????? Fmt? Attr PSize? PFree
/dev/sda2? vg_rootlhr?? lvm2 a--? 10.00g?????? 0
/dev/sda3? vg_rootlhr?? lvm2 a--?? 9.80g??? 1.80g
/dev/sdb1? vg_mysqlsoft lvm2 a--? 10.00g 1020.00m
/dev/sdb10????????????? lvm2 a--? 10.00g?? 10.00g
/dev/sdb11????????????? lvm2 a--?? 9.99g??? 9.99g
/dev/sdb2?????????????? lvm2 a--? 10.00g?? 10.00g
/dev/sdb3?????????????? lvm2 a--? 10.00g?? 10.00g
/dev/sdb5?????????????? lvm2 a--? 10.00g?? 10.00g
/dev/sdb6?????????????? lvm2 a--? 10.00g?? 10.00g
/dev/sdb7?????????????? lvm2 a--? 10.00g?? 10.00g
/dev/sdb8?????????????? lvm2 a--? 10.00g?? 10.00g
/dev/sdb9?????????????? lvm2 a--? 10.00g?? 10.00g
[root@LHRDB ~]# vgextend vg_mysqlsoft /dev/sdb2
Volume group "vg_mysqlsoft" successfully extended
[root@LHRDB ~]# vgs
VG?????????? #PV #LV #SN Attr?? VSize? VFree
vg_mysqlsoft?? 2?? 3?? 0 wz--n- 19.99g 10.99g
vg_rootlhr???? 2?? 4?? 0 wz--n- 19.80g? 1.80g
[root@LHRDB ~]#lvcreate -n lv_mysqlsoft_57sc -L 10G vg_mysqlsoft
Logical volume "lv_mysqlsoft_57sc" created
[root@LHRDB ~]#mkfs.ext4 /dev/vg_mysqlsoft/lv_mysqlsoft_57sc
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.? Use tune2fs -c or -i to override.
[root@LHRDB ~]# mkdir /usr/local/mysql57sc
[root@LHRDB ~]# chown mysql.mysql /usr/local/mysql57sc
[root@LHRDB ~]# mount /dev/vg_mysqlsoft/lv_mysqlsoft_57sc? /usr/local/mysql57sc/
[root@LHRDB ~]# df -h
Filesystem????????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00??????????????? 9.9G? 4.6G? 4.8G? 49% /
tmpfs?????????????????????????????????????? 2.0G?? 76K? 2.0G?? 1% /dev/shm
/dev/sda1?????????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01??????????????? 3.0G? 1.8G? 1.1G? 64% /tmp
/dev/mapper/vg_rootlhr-Vol03??????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57??? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56??? 2.0G? 1.4G? 575M? 70% /usr/local/mysql56
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55??? 2.0G? 848M? 1.1G? 45% /usr/local/mysql55
.host:/???????????????????????????????????? 331G? 273G?? 58G? 83% /mnt/hgfs
/dev/sr0??????????????????????????????????? 3.6G? 3.6G???? 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/sr0??????????????????????????????????? 3.6G? 3.6G???? 0 100% /media/lhr/cdrom
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57sc? 9.9G? 138M? 9.6G?? 1% /usr/local/mysql57sc
[root@LHRDB ~]# more /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Jan 14 18:56:24 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_rootlhr-Vol00 /?????????????????????? ext4??? defaults??????? 1 1
UUID=fccf51c1-2d2f-4152-baac-99ead8cfbc1a /boot?????????????????? ext4??? defaults??????? 1 2
/dev/mapper/vg_rootlhr-Vol01 /tmp??????????????????? ext4??? defaults??????? 1 2
/dev/mapper/vg_rootlhr-Vol02 swap??????????????????? swap??? defaults??????? 0 0
tmpfs?????????????????? /dev/shm??????????????? tmpfs?? defaults,size=2G??????? 0 0
devpts????????????????? /dev/pts??????????????? devpts? gid=5,mode=620? 0 0
sysfs?????????????????? /sys??????????????????? sysfs?? defaults??????? 0 0
proc??????????????????? /proc?????????????????? proc??? defaults??????? 0 0
/dev/vg_rootlhr/Vol03 /home? ext4 defaults??????? 0 0
/dev/vg_mysqlsoft/lv_mysqlsoft_57? /var/lib/mysql57? ext4??? defaults? 0 0
/dev/vg_mysqlsoft/lv_mysqlsoft_56? /usr/local/mysql56? ext4??? defaults? 0 0
/dev/vg_mysqlsoft/lv_mysqlsoft_55? /usr/local/mysql55? ext4??? defaults? 0 0
/dev/sr0 /media/lhr/cdrom iso9660 defaults,ro,loop 0 0
/dev/vg_mysqlsoft/lv_mysqlsoft_57sc? /usr/local/mysql57sc? ext4??? defaults? 0 0
1.11.4上傳并解壓
[root@LHRDB ~]# mkdir -p /tmp/mysql5.7sc
[root@LHRDB ~]# cd /tmp/mysql5.7sc
[root@LHRDB mysql5.7sc]# ll
total 98136
-rw-r--r-- 1 root root 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz
-rw-r--r-- 1 root root 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz
[root@LHRDB mysql5.7sc]#tar -zxf? /tmp/mysql5.7sc/mysql-5.7.19.tar.gz-C /usr/local/mysql57sc/
[root@LHRDB mysql5.7sc]#tar -zxf? /tmp/mysql5.7sc/mysql-boost-5.7.19.tar.gz-C /usr/local/mysql57sc/
[root@LHRDB mysql5.7sc]# ll
total 98140
drwxr-xr-x 36 7161 31415???? 4096 Jun 22 22:24 mysql-5.7.19
-rw-r--r--? 1 root root? 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz
-rw-r--r--? 1 root root? 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz
[root@LHRDB mysql5.7sc]# df -h
Filesystem????????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00??????????????? 9.9G? 4.7G? 4.8G? 50% /
tmpfs?????????????????????????????????????? 2.0G?? 76K? 2.0G?? 1% /dev/shm
/dev/sda1?????????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01??????????????? 3.0G? 1.6G? 1.3G? 56% /tmp
/dev/mapper/vg_rootlhr-Vol03??????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57??? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56??? 2.0G? 1.4G? 575M? 70% /usr/local/mysql56
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55??? 2.0G? 848M? 1.1G? 45% /usr/local/mysql55
.host:/???????????????????????????????????? 331G? 273G?? 58G? 83% /mnt/hgfs
/dev/sr0??????????????????????????????????? 3.6G? 3.6G???? 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/sr0??????????????????????????????????? 3.6G? 3.6G???? 0 100% /media/lhr/cdrom
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57sc9.9G? 683M9.4G7% /usr/local/mysql57sc
修改目錄的權(quán)限:
[root@LHRDB local]# cd? /usr/local/mysql57sc
[root@LHRDB mysql57sc]#mv mysql-5.7.19 mysql57
[root@LHRDB mysql57sc]# mkdir./mysql57/data
[root@LHRDB mysql57sc]# mkdir./mysql57/log
[root@LHRDB mysql57sc]#chown -R mysql.mysql .
1.11.5安裝編譯環(huán)境所需要的包和一些依賴包
1.11.5.1配置本地YUM源
mkdir -p /media/lhr/cdrom
mount /dev/sr0 /media/lhr/cdrom/
#設(shè)置開機自動掛載系統(tǒng)鏡像文件vi /etc/fstab添加以下內(nèi)容
/dev/sr0 /media/lhr/cdrom iso9660 defaults,ro,loop 0 0
cd /etc/yum.repos.d/
cp rhel-media.repo rhel-media.repo.bk
vi /etc/yum.repos.d/rhel-media.repo
[rhel-media]
name=Red Hat Enterprise Linux 6.5
baseurl=file:///media/lhr/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///media/lhr/cdrom/RPM-GPG-KEY-redhat-release
[root@LHRDB ~]# mkdir -p /media/lhr/cdrom
[root@LHRDB ~]# mount /dev/sr0 /media/lhr/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@LHRDB ~]# cd /etc/yum.repos.d/
[root@LHRDB yum.repos.d]# cp rhel-media.repo rhel-media.repo.bk
[root@LHRDB yum.repos.d]# more /etc/yum.repos.d/rhel-media.repo
[rhel-media]
name=Red Hat Enterprise Linux 6.5
baseurl=file:///media/lhr/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///media/lhr/cdrom/RPM-GPG-KEY-redhat-release
1.11.5.2安裝依賴包
yum install -y cmake make gcc gcc-c++ ncurses-devel
[root@LHRDB yum.repos.d]#yum install -y cmake make gcc gcc-c++ ncurses-devel
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-media???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? | 3.9 kB???? 00:00 ...
Setting up Install Process
Package 1:make-3.81-20.el6.x86_64 already installed and latest version
Package gcc-4.4.7-4.el6.x86_64 already installed and latest version
Package gcc-c++-4.4.7-4.el6.x86_64 already installed and latest version
Package ncurses-devel-5.7-3.20090208.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package cmake.x86_64 0:2.6.4-5.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================================
Package??????????????????????????????????????? Arch??????????????????????????????????????????? Version???????????????????????????????????????????????? Repository?????????????????????????????????????????? Size
==================================================================================================================================================================================================================
Installing:
cmake????????????????????????????????????????? x86_64????????????????????????????????????????? 2.6.4-5.el6???????????????????????????????????????????? rhel-media????????????????????????????????????????? 5.1 M
Transaction Summary
==================================================================================================================================================================================================================
Install?????? 1 Package(s)
Total download size: 5.1 M
Installed size: 17 M
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Retrieving key from file:///media/lhr/cdrom/RPM-GPG-KEY-redhat-release
Importing GPG key 0xFD431D51:
Userid: "Red Hat, Inc. (release key 2) "
From? : /media/lhr/cdrom/RPM-GPG-KEY-redhat-release
Importing GPG key 0x2FA658E0:
Userid: "Red Hat, Inc. (auxiliary key) "
From? : /media/lhr/cdrom/RPM-GPG-KEY-redhat-release
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : cmake-2.6.4-5.el6.x86_64?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 1/1
Verifying? : cmake-2.6.4-5.el6.x86_64?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 1/1
Installed:
cmake.x86_64 0:2.6.4-5.el6
Complete!
注意:這里的cmake最低需要2.8.2版本的早龟,不然會報錯暇藏,先接著往下做吧楣颠。
1.11.6執(zhí)行編譯命令
1.11.6.1升級cmake的版本
[root@LHRDB mysql-5.7.19]# cmake -version
cmake version 2.6-patch 4
[root@LHRDB mysql-5.7.19]# pwd
/tmp/mysql5.7sc/mysql-5.7.19
[root@LHRDB mysql-5.7.19]# ll
total 332
drwxr-xr-x? 3 7161 31415? 4096 Jun 22 22:24 boost
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 BUILD
drwxr-xr-x? 6 7161 31415? 4096 Jun 22 22:24 client
drwxr-xr-x? 4 7161 31415? 4096 Jun 22 22:24 cmake
-rw-r--r--? 1 7161 31415 26727 Jun 22 22:13 CMakeLists.txt
drwxr-xr-x? 3 7161 31415? 4096 Jun 22 22:24 cmd-line-utils
-rw-r--r--? 1 7161 31415 13832 Jun 22 22:13 config.h.cmake
-rw-r--r--? 1 7161 31415 33704 Jun 22 22:13 configure.cmake
-rw-r--r--? 1 7161 31415 17987 Jun 22 22:13 COPYING
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 dbug
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 Docs
-rw-r--r--? 1 7161 31415 66241 Jun 22 22:13 Doxyfile-perfschema
drwxr-xr-x? 6 7161 31415? 4096 Jun 22 22:24 extra
drwxr-xr-x? 5 7161 31415? 4096 Jun 22 22:24 include
-rw-r--r--? 1 7161 31415?? 333 Jun 22 22:13 INSTALL
drwxr-xr-x? 5 7161 31415? 4096 Jun 22 22:24 libbinlogevents
drwxr-xr-x? 3 7161 31415? 4096 Jun 22 22:24 libbinlogstandalone
drwxr-xr-x? 7 7161 31415? 4096 Jun 22 22:24 libevent
drwxr-xr-x? 4 7161 31415? 4096 Jun 22 22:24 libmysql
drwxr-xr-x? 3 7161 31415? 4096 Jun 22 22:24 libmysqld
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 libservices
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 man
drwxr-xr-x 10 7161 31415? 4096 Jun 22 22:24 mysql-test
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 mysys
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 mysys_ssl
drwxr-xr-x 10 7161 31415? 4096 Jun 22 22:24 packaging
drwxr-xr-x 18 7161 31415? 4096 Jun 22 22:24 plugin
drwxr-xr-x? 4 7161 31415? 4096 Jun 22 22:24 rapid
-rw-r--r--? 1 7161 31415? 2478 Jun 22 22:13 README
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 regex
drwxr-xr-x? 3 7161 31415? 4096 Jun 22 22:24 scripts
drwxr-xr-x? 7 7161 31415 20480 Jun 22 22:24 sql
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 sql-common
drwxr-xr-x 14 7161 31415? 4096 Jun 22 22:24 storage
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 strings
drwxr-xr-x? 4 7161 31415? 4096 Jun 22 22:24 support-files
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 testclients
drwxr-xr-x? 5 7161 31415? 4096 Jun 22 22:24 unittest
-rw-r--r--? 1 7161 31415??? 88 Jun 22 22:13 VERSION
drwxr-xr-x? 3 7161 31415? 4096 Jun 22 22:24 vio
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 win
drwxr-xr-x? 2 7161 31415? 4096 Jun 22 22:24 zlib
[root@LHRDB mysql-5.7.19]#cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57sc/mysql57 \
> -DMYSQL_DATADIR=/usr/local/mysql57sc/mysql57/data \
> -DMYSQL_USER=mysql \
> -DWITH_INNOBASE_STORAGE_ENGINE=1? \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1?? \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DDOWNLOAD_BOOST=1 \
> -DWITH_BOOST=/usr/local/mysql57sc/mysql57/boost/boost_1_59_0/
CMake Error at CMakeLists.txt:21 (CMAKE_MINIMUM_REQUIRED):
CMake 2.8.2 or higher is required.? You are running version 2.6.4
-- Configuring incomplete, errors occurred!
cmake每個參數(shù)的介紹參考:http://blog.itpub.net/26736162/viewspace-2144212/
下載高版本cmake,http://www.cmake.org/cmake/resources/software.html鬼癣,解壓縮cmake-3.9.1.tar.gz饵骨,解壓后執(zhí)行“./bootstrap && make && make install”,如下:
[root@LHRDB ~]# cd /tmp/mysql5.7sc/
[root@LHRDB mysql5.7sc]# ll
total 105664
-rw-r--r--? 1 root root?? 7702497 Aug 28 10:20 cmake-3.9.1.tar.gz
drwxr-xr-x 37 7161 31415???? 4096 Aug 28 10:38 mysql-5.7.19
-rw-r--r--? 1 root root? 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz
-rw-r--r--? 1 root root? 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz
[root@LHRDB mysql5.7sc]#tar -zxf cmake-3.9.1.tar.gz
[root@LHRDB mysql5.7sc]# ll
total 105668
drwxr-xr-x 11 root root????? 4096 Aug 28 10:42 cmake-3.9.1
-rw-r--r--? 1 root root?? 7702497 Aug 28 10:20 cmake-3.9.1.tar.gz
drwxr-xr-x 37 7161 31415???? 4096 Aug 28 10:38 mysql-5.7.19
-rw-r--r--? 1 root root? 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz
-rw-r--r--? 1 root root? 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz
[root@LHRDB mysql5.7sc]# cd cmake-3.9.1
[root@LHRDB cmake-3.9.1]# ll
total 284
drwxr-xr-x?? 4 502 games? 4096 Aug 10 21:47 Auxiliary
-rwxr-xr-x?? 1 502 games 48336 Aug 10 21:36 bootstrap
-rw-r--r--?? 1 502 games? 9706 Aug 10 21:36 CMakeCPack.cmake
-rw-r--r--?? 1 502 games 12897 Aug 10 21:36 CMakeCPackOptions.cmake.in
-rw-r--r--?? 1 502 games?? 153 Aug 10 21:36 CMakeGraphVizOptions.cmake
-rw-r--r--?? 1 502 games 31721 Aug 10 21:36 CMakeLists.txt
-rw-r--r--?? 1 502 games? 4481 Aug 10 21:36 CMakeLogo.gif
-rw-r--r--?? 1 502 games?? 790 Aug 10 21:36 cmake_uninstall.cmake.in
-rw-r--r--?? 1 502 games? 3322 Aug 10 21:36 CompileFlags.cmake
-rwxr-xr-x?? 1 502 games??? 99 Aug 10 21:36 configure
-rw-r--r--?? 1 502 games? 1851 Aug 10 21:36 CONTRIBUTING.rst
-rw-r--r--?? 1 502 games? 4999 Aug 10 21:36 Copyright.txt
-rw-r--r--?? 1 502 games?? 440 Aug 10 21:36 CTestConfig.cmake
-rw-r--r--?? 1 502 games? 6213 Aug 10 21:36 CTestCustom.cmake.in
-rw-r--r--?? 1 502 games?? 374 Aug 10 21:36 DartConfig.cmake
-rw-r--r--?? 1 502 games 28046 Aug 10 21:36 doxygen.config
drwxr-xr-x? 18 502 games? 4096 Aug 10 21:47 Help
drwxr-xr-x?? 2 502 games? 4096 Aug 10 21:47 Licenses
drwxr-xr-x? 12 502 games 20480 Aug 10 21:47 Modules
drwxr-xr-x?? 3 502 games? 4096 Aug 10 21:47 Packaging
-rw-r--r--?? 1 502 games? 3016 Aug 10 21:36 README.rst
drwxr-xr-x? 11 502 games 36864 Aug 10 21:47 Source
drwxr-xr-x?? 4 502 games? 4096 Aug 10 21:47 Templates
drwxr-xr-x 240 502 games 12288 Aug 10 21:47 Tests
drwxr-xr-x? 21 502 games? 4096 Aug 10 21:47 Utilities
[root@LHRDB cmake-3.9.1]#
[root@LHRDB cmake-3.9.1]#./bootstrap && make && make install
---------------------------------------------
CMake 3.9.1, Copyright 2000-2017 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc? -std=gnu99
C++ compiler on this system is: g++? -std=gnu++0x
Makefile processor on this system is: gmake
g++ is GNU compiler
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has
---------------------------------------------
g++? -std=gnu++0x???? -I/tmp/mysql5.7sc/cmake-3.9.1/Bootstrap.cmk?? -I/tmp/mysql5.7sc/cmake-3.9.1/Source?? -I/tmp/mysql5.7sc/cmake-3.9.1/Source/LexerParser?? -I/tmp/mysql5.7sc/cmake-3.9.1/Utilities? -c /tmp/mysql5.7sc/cmake-3.9.1/Source/cmAddCustomCommandCommand.cxx -o cmAddCustomCommandCommand.o
g++? -std=gnu++0x???? -I/tmp/mysql5.7sc/cmake-3.9.1/Bootstrap.cmk?? -I/tmp/mysql5.7sc/cmake-3.9.1/Source?? -I/tmp/mysql5.7sc/cmake-3.9.1/Source/LexerParser?? -I/tmp/mysql5.7sc/cmake-3.9.1/Utilities? -c /tmp/mysql5.7sc/cmake-3.9.1/Source/cmAddCustomTargetCommand.cxx -o cmAddCustomTargetCommand.o
茫打。居触。。老赤。轮洋。。抬旺。弊予。。开财。汉柒。。责鳍。碾褂。 省略 。历葛。正塌。。。乓诽。帜羊。。鸠天。讼育。。粮宛。窥淆。。巍杈。
-- Installing: /usr/local/bin/cmake
-- Installing: /usr/local/bin/ctest
-- Installing: /usr/local/bin/cpack
-- Installing: /usr/local/share/cmake-3.9/include/cmCPluginAPI.h
-- Installing: /usr/local/share/cmake-3.9/editors/vim/indent
-- Installing: /usr/local/share/cmake-3.9/editors/vim/indent/cmake.vim
-- Installing: /usr/local/share/cmake-3.9/editors/vim/syntax
-- Installing: /usr/local/share/cmake-3.9/editors/vim/syntax/cmake.vim
-- Installing: /usr/local/share/cmake-3.9/editors/emacs/cmake-mode.el
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/cmake-3.9/completions/cmake
-- Installing: /usr/local/share/cmake-3.9/completions/cpack
-- Installing: /usr/local/share/cmake-3.9/completions/ctest
[root@LHRDB cmake-3.9.1]# which cmake
/usr/local/bin/cmake
[root@LHRDB cmake-3.9.1]# cmake -version
cmake version 3.9.1
重新開一個shell并繼續(xù)編譯:
[root@LHRDB mysql57]#cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57sc/mysql57 \
> -DMYSQL_DATADIR=/usr/local/mysql57sc/mysql57/data \
> -DMYSQL_USER=mysql \
> -DWITH_INNOBASE_STORAGE_ENGINE=1? \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1?? \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DDOWNLOAD_BOOST=1 \
> -DWITH_BOOST=/usr/local/mysql57sc/mysql57/boost/boost_1_59_0/
CMake Deprecation Warning at CMakeLists.txt:26 (CMAKE_POLICY):
The OLD behavior for policy CMP0018 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances.? Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at CMakeLists.txt:32 (CMAKE_POLICY):
The OLD behavior for policy CMP0022 will be removed from a future version
of CMake.
忧饭。。筷畦。词裤。。鳖宾。吼砂。。省略部分鼎文。渔肩。。拇惋。周偎。。撑帖。蓉坎。
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances.? Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- INSTALL mysqlclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_LIBEVENT1
-- CMAKE_C_FLAGS:? -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS:? -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/mysql57sc/mysql57
成功。
1.11.6.2編譯安裝
該過程最慢胡嘿。蛉艾。。衷敌。勿侯。虛擬機約40分鐘。逢享。罐监。。
[root@LHRDB mysql57]#make && make install
Scanning dependencies of target abi_check
[? 0%] Built target abi_check
Scanning dependencies of target INFO_SRC
[? 0%] Built target INFO_SRC
Scanning dependencies of target INFO_BIN
[? 0%] Built target INFO_BIN
Scanning dependencies of target zlib
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/compress.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/crc32.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/deflate.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/gzio.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/infback.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/inffast.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/inflate.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/inftrees.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/trees.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/uncompr.c.o
[? 0%] Building C object zlib/CMakeFiles/zlib.dir/zutil.c.o
瞒爬。弓柱。沟堡。。矢空。航罗。。屁药。粥血。。省略部分酿箭。复亏。。缭嫡。缔御。。妇蛀。耕突。。评架。眷茁。。
-- Installing: /usr/local/mysql57sc/mysql57/share/fill_help_tables.sql
-- Installing: /usr/local/mysql57sc/mysql57/share/mysql_sys_schema.sql
-- Installing: /usr/local/mysql57sc/mysql57/share/mysql_test_data_timezone.sql
-- Installing: /usr/local/mysql57sc/mysql57/share/mysql_security_commands.sql
-- Installing: /usr/local/mysql57sc/mysql57/lib/pkgconfig/mysqlclient.pc
-- Installing: /usr/local/mysql57sc/mysql57/bin/mysql_config
-- Installing: /usr/local/mysql57sc/mysql57/bin/mysqldumpslow
-- Installing: /usr/local/mysql57sc/mysql57/bin/mysqld_multi
-- Installing: /usr/local/mysql57sc/mysql57/bin/mysqld_safe
-- Installing: /usr/local/mysql57sc/mysql57/share/aclocal/mysql.m4
[root@LHRDB mysql57]#
[root@LHRDB mysql57]# df -h
Filesystem????????????????????????????????? Size? Used Avail Use% Mounted on
/dev/mapper/vg_rootlhr-Vol00??????????????? 9.9G? 4.7G? 4.8G? 50% /
tmpfs?????????????????????????????????????? 2.0G?? 72K? 2.0G?? 1% /dev/shm
/dev/sda1?????????????????????????????????? 194M?? 35M? 150M? 19% /boot
/dev/mapper/vg_rootlhr-Vol01??????????????? 3.0G? 1.6G? 1.3G? 56% /tmp
/dev/mapper/vg_rootlhr-Vol03??????????????? 3.0G?? 69M? 2.8G?? 3% /home
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57??? 5.0G? 2.7G? 2.0G? 58% /var/lib/mysql57
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56??? 2.0G? 1.4G? 575M? 70% /usr/local/mysql56
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55??? 2.0G? 848M? 1.1G? 45% /usr/local/mysql55
/dev/sr0??????????????????????????????????? 3.6G? 3.6G???? 0 100% /media/lhr/cdrom
/dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57sc? 9.9G? 7.2G? 2.2G? 77% /usr/local/mysql57sc
.host:/???????????????????????????????????? 331G? 273G?? 58G? 83% /mnt/hgfs
用了大概7.2G纵诞,太費空間了上祈。最后的make和make install大概用了40分鐘,太費時間了浙芙。雇逞。。茁裙。。
1.11.7初始化MySQL
注意:MySQL5.7.6之后的版本初始化數(shù)據(jù)庫不再使用mysql_install_db
[root@LHRDB mysql57]# mkdir log
[root@LHRDB mysql57]# chown mysql.mysql log
[root@LHRDB mysql57]# pwd
/usr/local/mysql57sc/mysql57
[root@LHRDB mysql57]#./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql57sc/mysql57? --datadir=/usr/local/mysql57sc/mysql57/data
2017-08-28T08:34:01.250285Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-28T08:34:02.675706Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-08-28T08:34:02.743783Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-28T08:34:02.847128Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a572bb0e-8bcb-11e7-b92e-000c291823c2.
2017-08-28T08:34:02.848708Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-08-28T08:34:02.851802Z 1 [Note] A temporary password is generated for root@localhost:N9eYPaqv4q!X
這里生成的臨時密碼為:N9eYPaqv4q!X
1.11.8配置/etc/my.cnf
修改文件/etc/my.cnf节仿,加入以下內(nèi)容:
[mysqld573309]
basedir=/usr/local/mysql57sc/mysql57
datadir=/usr/local/mysql57sc/mysql57/data
socket=/usr/local/mysql57sc/mysql57/mysql.sock
log-error=/usr/local/mysql57sc/mysql57/log/mysqld.log
user=mysql
port=3309
1.11.9啟動MySQL
[root@LHRDB mysql5719]#echo '' > /usr/local/mysql57sc/mysql57/log/mysqld.log
[root@LHRDB mysql5719]#chown mysql.mysql /usr/local/mysql57sc/mysql57/log/mysqld.log
[root@LHRDB data]# mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld57 is running
MySQL server from group: mysqld56 is running
MySQL server from group: mysqld55 is running
MySQL server from group: mysqld573309 is not running
[root@LHRDB data]#mysqld_multi start573309
[root@LHRDB data]#mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld57 is running
MySQL server from group: mysqld56 is running
MySQL server from group: mysqld55 is running
MySQL server from group: mysqld573309 is running
[root@LHRDB data]#netstat -lntp | grep mysqld
tcp??????? 0????? 0 0.0.0.0:3308??????????????? 0.0.0.0:*?????????????????? LISTEN????? 12932/mysqld
tcp??????? 0????? 0 :::3307???????????????????? :::*??????????????????????? LISTEN????? 12858/mysqld
tcp??????? 0????? 0 :::3309???????????????????? :::*??????????????????????? LISTEN????? 29785/mysqld
tcp??????? 0????? 0 :::3306???????????????????? :::*??????????????????????? LISTEN????? 12880/mysqld
1.11.10登錄MySQL并修改密碼
[root@LHRDB data]#mysql -uroot? --socket=/usr/local/mysql57sc/mysql57/mysql.sock -p
Enter password:
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>set password=password('lhr');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> select @@port;
+--------+
| @@port |
+--------+
|?? 3309 |
+--------+
1 row in set (0.00 sec)
修改密碼也可以用:update mysql.user set authentication_string=password('lhr') where user='root';
1.11.11設(shè)置遠程登錄
mysql>grant all privileges on *.* to root@'%' identified by 'lhr';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>select host,user from mysql.user;
+-----------+---------------+
| host????? | user????????? |
+-----------+---------------+
| %???????? | root????????? |
| localhost | mysql.session |
| localhost | mysql.sys???? |
| localhost | root????????? |
+-----------+---------------+
4 rows in set (0.00 sec)
1.11.12Windows遠程登錄
在Windows下遠程登錄:
D:\Users\xiaomaimiao>mysql -uroot -plhr -h192.168.59.159 -P3309
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.19 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
| sys??????????????? |
+--------------------+
4 rows in set (0.00 sec)
mysql>
1.12錯誤解決
1.12.1ABORT: Can't find command 'my_print_defaults'.
[root@LHRDB ~]# service mysqld_multi start
WARNING: my_print_defaults command not found.
Please make sure you have this command available and
in your path. The command is available from the latest
MySQL distribution.
WARNING: Log file disabled. Maybe directory or file isn't writable?
ABORT: Can't find command 'my_print_defaults'.
This command is available from the latest MySQL
distribution. Please make sure you have the command
in your PATH.
解決:
編輯文件:/etc/init.d/mysqld_multi晤锥,添加:. /etc/profile,或者在文件/etc/init.d/mysqld_multi中加入下面的變量:
MYSQL_HOME=/var/lib/mysql57/mysql5719
PATH=$MYSQL_HOME/bin:$PATH
1.12.2執(zhí)行cmake編譯時報錯
CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=
This CMake script will look for boost in . If it is not there,
it will download and unpack it (in that directory) for you.**
解決辦法:
cmake -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/mysql-5.7.19/boost/boost_1_59_0/
或者在執(zhí)行cmake命令時加上DOWNLOAD_BOOST和WITH_BOOST參數(shù)廊宪。
1.13參考文檔
官方文檔:
https://dev.mysql.com/doc/refman/5.7/en/checking-rpm-signature.html
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
https://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html
源碼編譯安裝的更多內(nèi)容:http://blog.itpub.net/26736162/viewspace-2144212/
rpm的安裝方式請參考:
http://blog.itpub.net/26736162/viewspace-1349705/
http://blog.itpub.net/26736162/viewspace-1349787/
第二章實驗中用到的SQL總結(jié)
OS路徑設(shè)置:
vgcreate vg_mysqlsoft /dev/sdb1
lvcreate -n lv_mysqlsoft_57 -L 5G vg_mysqlsoft
mkfs.ext4 /dev/vg_mysqlsoft/lv_mysqlsoft_57
mkdir -p /tmp/mysql5719
mkdir -p /var/lib/mysql57
mount /dev/vg_mysqlsoft/lv_mysqlsoft_57? /var/lib/mysql57/
vi /etc/fstab
二進制安裝過程:
md5sum mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /var/lib/mysql57/
mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql5719
groupadd mysql
useradd -r -g mysql mysql
MySQL 5.6版本:./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql56/mysql5637 --datadir=/usr/local/mysql56/mysql5637/data
MySQL 5.7版本:./bin/mysqld --initialize --user=mysql --basedir=/var/lib/mysql57/mysql5719? --datadir=/var/lib/mysql57/mysql5719/data
more /etc/my.cnf
cp mysql.server /etc/init.d/mysql57
chmod 755 /etc/init.d/mysql57
chkconfig --add mysql57
chkconfig mysql57 on
chkconfig --level 345 mysql57 on
mysqld_safe --user=mysql &
MYSQL_HOME=/var/lib/mysql57/mysql5719
PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile
#MySQL 5.7初始化時有默認密碼矾瘾,5.6無密碼
mysql -uroot? --socket=/usr/local/mysql56/mysql5637/mysql.sock -p
set password=password('lhr');
update mysql.user set authentication_string=password('lhr') where user='root';
grant all privileges on *.* to root@'%' identified by 'lhr';
flush privileges;
源碼安裝:
tar -zxf? /tmp/mysql5.7sc/mysql-5.7.19.tar.gz -C /usr/local/mysql57sc/
tar -zxf? /tmp/mysql5.7sc/mysql-boost-5.7.19.tar.gz -C /usr/local/mysql57sc/
mv mysql-5.7.19 mysql57
yum install -y cmake make gcc gcc-c++ ncurses-devel
#cmake最低需要2.8.2版本的
cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57sc/mysql57 \
> -DMYSQL_DATADIR=/usr/local/mysql57sc/mysql57/data \
> -DMYSQL_USER=mysql \
> -DWITH_INNOBASE_STORAGE_ENGINE=1? \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1?? \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DDOWNLOAD_BOOST=1 \
> -DWITH_BOOST=/usr/local/mysql57sc/mysql57/boost/boost_1_59_0/
make && make install
查看MySQL的端口:
netstat -lntp | grep mysqld
About Me
.............................................................................................................................................
● 本文作者:小麥苗,只專注于數(shù)據(jù)庫的技術(shù)箭启,更注重技術(shù)的運用
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)壕翩、博客園(http://www.cnblogs.com/lhrbest)和個人微信公眾號(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/viewspace-2144261/
● 本文博客園地址:http://www.cnblogs.com/lhrbest/p/7445468.html
● 本文pdf版、個人簡介及小麥苗云盤地址:http://blog.itpub.net/26736162/viewspace-1624453/
● 數(shù)據(jù)庫筆試面試題庫及解答:http://blog.itpub.net/26736162/viewspace-2134706/
● DBA寶典今日頭條號地址:http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群號:230161599(滿)傅寡、618766405
● 微信群:可加我微信放妈,我拉大家進群北救,非誠勿擾
● 聯(lián)系我請加QQ好友(646634621),注明添加緣由
● 于 2017-08-23 09:00 ~ 2017-08-28 22:00 在魔都完成 ?農(nóng)歷七月七日 七夕節(jié) 情人節(jié) 單身狗
● 文章內(nèi)容來源于小麥苗的學(xué)習(xí)筆記芜抒,部分整理自網(wǎng)絡(luò)珍策,若有侵權(quán)或不當(dāng)之處還請諒解
● 版權(quán)所有,歡迎分享本文宅倒,轉(zhuǎn)載請保留出處
.............................................................................................................................................
●小麥苗的微店:https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
●小麥苗出版的數(shù)據(jù)庫類叢書:http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用微信客戶端掃描下面的二維碼來關(guān)注小麥苗的微信公眾號(xiaomaimiaolhr)及QQ群(DBA寶典)攘宙,學(xué)習(xí)最實用的數(shù)據(jù)庫技術(shù)。
小麥苗的微信公眾號 ? ? ?小麥苗的DBA寶典QQ群1小麥苗的DBA寶典QQ群2小麥苗的微店
.............................................................................................................................................