1、系統(tǒng)及安裝說(shuō)明
成都創(chuàng)新互聯(lián)公司是專業(yè)的冀州網(wǎng)站建設(shè)公司,冀州接單;提供網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行冀州網(wǎng)站開發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
系統(tǒng):CentOS6.x_x64
MySQL:社區(qū)版5.6.21,開源數(shù)據(jù)庫(kù)用的最多的mysql,編譯安裝比較繁瑣,yum安裝版本比較低且默認(rèn)安裝的位置是/var/下,本次采用官方下載的rpm包,通過(guò)腳本自動(dòng)化安裝并定制數(shù)據(jù)目錄到獨(dú)立分區(qū)中(本次為/data目錄)
2、準(zhǔn)備安裝包
1>官方下載
#https://dev.mysql.com/downloads/mysql/5.6.html#downloads 選擇對(duì)應(yīng)的版本和平臺(tái)軟件包:
MySQL-shared-compat-5.6.x-1.el6.x86_64.rpm #x就是你下的版本號(hào)以下類同
MySQL-devel-5.6.x-1.el6.x86_64.rpm
MySQL-shared-5.6.x-1.el6.x86_64.rpm
MySQL-client-5.6.x-1.el6.x86_64.rpm
MySQL-test-5.6.x-1.el6.x86_64.rpm
MySQL-server-5.6.x-1.el6.x86_64.rpm
2>本實(shí)驗(yàn)用到的包
https://pan.baidu.com/s/1kVraS8R 密碼: iybx
包含了以下軟件包:
MySQL-shared-compat-5.6.21-1.el6.x86_64.rpm
MySQL-devel-5.6.21-1.el6.x86_64.rpm
MySQL-shared-5.6.21-1.el6.x86_64.rpm
MySQL-client-5.6.21-1.el6.x86_64.rpm
MySQL-test-5.6.21-1.el6.x86_64.rpm
MySQL-server-5.6.21-1.el6.x86_64.rpm
2>mysql數(shù)據(jù)庫(kù)默認(rèn)的一些主要目錄:
1、數(shù)據(jù)庫(kù)目錄 /var/lib/mysql/
2、配置文件 /usr/share/mysql(mysql.server命令及配置文件)
3、相關(guān)命令 /usr/bin (mysqladmin mysqldump等命令)
4、啟動(dòng)腳本 /etc/rc.d/init.d/(啟動(dòng)腳本文件mysql的目錄)
5、修改配置文件位置 cp /usr/share/mysql/my-default.cnf /etc/my.cnf
3、安裝
1>如果是官方下載的請(qǐng)直接執(zhí)行下面操作
#rpm -ivh MySQL-shared-compat-5.6.x-1.el6.x86_64.rpm #提供基礎(chǔ)依賴組件,需要第一個(gè)安裝 #yum remove mysql-libs -y #御載默認(rèn)自帶的mysql-lib #yum install libaio -y #安裝libiao #rpm -ivh MySQL-devel-5.6.x-1.el6.x86_64.rpm #rpm -ivh MySQL-shared-5.6.x-1.el6.x86_64.rpm #rpm -ivh MySQL-client-5.6.x-1.el6.x86_64.rpm #rpm -ivh MySQL-test-5.6.x-1.el6.x86_64.rpm #rpm -ivh MySQL-server-5.6.x-1.el6.x86_64.rpm
說(shuō)明:以上直接安裝的數(shù)據(jù)目錄在
/var/lib/mysql
下,你也可以自定義數(shù)據(jù)目錄在一個(gè)分區(qū)(磁盤)上
因此可通過(guò)腳本重新初始化安裝到別的目錄;完成自定制;
2>腳本執(zhí)行
#!/bin/bash src_dir=$(pwd) cd $src_dir tar xvf mysql5.6.21.x86_64.rpms.tar.gz tar xvf mysql5.6.21.x86_64.rpms.tar cd mysql5.6.21 rpm -ivh MySQL-shared-compat-5.6.21-1.el6.x86_64.rpm yum remove mysql-libs -y yum install libaio -y rpm -ivh MySQL-devel-5.6.21-1.el6.x86_64.rpm rpm -ivh MySQL-shared-5.6.21-1.el6.x86_64.rpm rpm -ivh MySQL-client-5.6.21-1.el6.x86_64.rpm rpm -ivh MySQL-test-5.6.21-1.el6.x86_64.rpm rpm -ivh MySQL-server-5.6.21-1.el6.x86_64.rpm #service mysql start && echo "mysql5.6.21 has installes sucess!" #mysql_root_pwd=`gawk -F : '{ print $4 }' /root/.mysql_secret` #echo "A random root password has been set. You will find it in '/root/.mysql_secret'." #echo "The random root password was:'${mysql_root_pwd// }'" service mysql stop [ -d /data/mysqldb/data ] || mkdir -p /data/mysqldb/data [ -d /data/mysqldb/log ] || mkdir -p /data/mysqldb/log chown mysql.mysql /data/mysqldb -R cd /usr/bin ./mysql_install_db --user=mysql --basedir=/usr --datadir=/data/mysqldb/data #遷移數(shù)據(jù)目錄到/data/mysqldb/data下可自行定制 cd $src_dir cp ${src_dir}/my.cnf /etc cd /var/lib mv mysql /tmp mkdir mysql chown mysql.mysql mysql service mysql start && echo "Mysql root password was empty.Please change when you login mysql." ln -s /data/mysqldb/data/mysql.sock /var/lib/mysql/mysql.sock #由于一些mysql工具默認(rèn)到這里找mysql.sock所以做個(gè)軟鏈 4、注意事項(xiàng) mysql服務(wù)的root密碼為空,請(qǐng)自行修改root密碼?;蛟谀_本中添加以下行 在mysql遷移好目錄啟動(dòng)后自動(dòng)修改mysql root密碼 |
mysqladmin -u root password "123456"