日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯網營銷解決方案
創(chuàng)新互聯linux教程:20.2.1配置Mysql服務

本書在第18章講解過MySQL和MariaDB數據庫管理系統(tǒng)之間的因緣和特性,也狠狠地夸獎了MariaDB數據庫,但是MySQL數據庫當前依然是生產環(huán)境中最常使用的關系型數據庫管理系統(tǒng)之一,坐擁極大的市場份額,并且已經通過十幾年不斷的發(fā)展向業(yè)界證明了自身的穩(wěn)定性和安全性。另外,雖然第18章已經講解了基本的數據庫管理知識,但是為了進一步幫助大家夯實基礎,本章依然在這里整合了MySQL數據庫內容,使大家在溫故的同時可以知新。

創(chuàng)新互聯是專業(yè)的陽曲網站建設公司,陽曲接單;提供成都做網站、網站制作,網頁設計,網站設計,建網站,PHP網站建設等專業(yè)做網站服務;采用PHP框架,可快速的進行陽曲網站開發(fā)網頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網站,專業(yè)的做網站團隊,希望更多企業(yè)前來合作!

在使用Yum軟件倉庫安裝服務程序時,系統(tǒng)會自動根據RPM軟件包中的指令集完整軟件配置等工作。但是一旦選擇使用源碼包的方式來安裝,這一切就需要自己來完成了。針對MySQL數據庫來講,我們需要在系統(tǒng)中創(chuàng)建一個名為mysql的用戶,專門用于負責運行MySQL數據庫。請記得要把這類賬戶的Bash終端設置成nologin解釋器,避免黑客通過該用戶登錄到服務器中,從而提高系統(tǒng)安全性。

    [root@linuxprobe cmake-2.8.11.2]# cd ..
    [root@linuxprobe src]# useradd mysql -s /sbin/nologin

創(chuàng)建一個用于保存MySQL數據庫程序和數據庫文件的目錄,并把該目錄的所有者和所屬組身份修改為mysql。其中,/usr/local/mysql是用于保存MySQL數據庫服務程序的目錄,/usr/local/mysql/var則是用于保存真實數據庫文件的目錄。

    [root@linuxprobe src]# mkdir -p /usr/local/mysql/var
    [root@linuxprobe src]# chown -Rf mysql:mysql /usr/local/mysql

接下來解壓、編譯、安裝MySQL數據庫服務程序。在編譯數據庫時使用的是cmake命令,其中,-DCMAKE_INSTALL_PREFIX參數用于定義數據庫服務程序的保存目錄,-DMYSQL_DATADIR參數用于定義真實數據庫文件的目錄,-DSYSCONFDIR則是定義MySQL數據庫配置文件的保存目錄。由于MySQL數據庫服務程序比較大,因此編譯的過程比較漫長,在此期間可以稍微休息一下。

    [root@linuxprobe src]# tar xzvf mysql-5.6.19.tar.gz
    [root@linuxprobe src]# cd mysql-5.6.19/
    [root@linuxprobe mysql-5.6.19]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc
    [root@linuxprobe mysql-5.6.19]# make
    [root@linuxprobe mysql-5.6.19]# make install

為了讓MySQL數據庫程序正常運轉起來,需要先刪除/etc目錄中的默認配置文件,然后在MySQL數據庫程序的保存目錄scripts內找到一個名為mysql_install_db的腳本程序,執(zhí)行這個腳本程序并使用--user參數指定MySQL服務的對應賬號名稱(在前面步驟已經創(chuàng)建),使用--basedir參數指定MySQL服務程序的保存目錄,使用--datadir參數指定MySQL真實數據庫的文件保存目錄,這樣即可生成系統(tǒng)數據庫文件,也會生成出新的MySQL服務配置文件。

    [root@linuxprobe mysql-5.6.19]# rm -rf /etc/my.cnf
    [root@linuxprobe mysql-5.6.19]# cd /usr/local/mysql
    [root@linuxprobe mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var

把系統(tǒng)新生成的MySQL數據庫配置文件鏈接到/etc目錄中,然后把程序目錄中的開機程序文件復制到/etc/rc.d/init.d目錄中,以便通過service命令來管理MySQL數據庫服務程序。記得把數據庫腳本文件的權限修改成755以便于讓用戶有執(zhí)行該腳本的權限:

    [root@linuxprobe mysql]# ln -s my.cnf /etc/my.cnf 
    [root@linuxprobe mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
    [root@linuxprobe mysql]# chmod 755 /etc/rc.d/init.d/mysqld

編輯剛復制的MySQL數據庫腳本文件,把第46、47行的basedir與datadir參數分別修改為MySQL數據庫程序的保存目錄和真實數據庫的文件內容。

    [root@linuxprobe mysql]# vim /etc/rc.d/init.d/mysqld 
    ………………省略部分輸出信息………………
     39 #
     40 # If you want to affect other MySQL variables, you should make your changes
     41 # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
     42 
     43 # If you change base dir, you must also change datadir. These may get
     44 # overwritten by settings in the MySQL configuration files.
     45 
     46 basedir=/usr/local/mysql
     47 datadir=/usr/local/mysql/var
     48 
    ………………省略部分輸出信息………………

配置好腳本文件后便可以用service命令啟動mysqld數據庫服務了。mysqld是MySQL數據庫程序的服務名稱,注意不要寫錯。順帶再使用chkconfig命令把mysqld服務程序加入到開機啟動項中。

    [root@Linuxprobe mysql]# service mysqld start
    Starting MySQL. SUCCESS! 
    [root@linuxprobe mysql]# chkconfig mysqld on

MySQL數據庫程序自帶了許多命令,但是Bash終端的PATH變量并不會包含這些命令所存放的目錄,因此我們也無法順利地對MySQL數據庫進行初始化,也就不能使用MySQL數據庫自帶的命令了。想要把命令所保存的目錄永久性地定義到PATH變量中,需要編輯/etc/profile文件并寫入追加的命令目錄,這樣當物理設備在下一次重啟時就會永久生效了。如果不想通過重啟設備的方式來生效,也可以使用source命令加載一下/ect/profile文件,此時新的PATH變量也可以立即生效了。

    [root@linuxprobe mysql]# vim /etc/profile
    ………………省略部分輸出信息………………
     64 
     65 for i in /etc/profile.d/*.sh ; do
     66 if [ -r "$i" ]; then
     67 if [ "${-#*i}" != "$-" ]; then
     68 . "$i"
     69 else
     70 . "$i" >/dev/null
     71 fi
     72 fi
     73 done
     74 export PATH=$PATH:/usr/local/mysql/bin
     75 unset i
     76 unset -f pathmunge
    [root@linuxprobe mysql]# source /etc/profile

MySQL數據庫服務程序還會調用到一些程序文件和函數庫文件。由于當前是通過源碼包方式安裝MySQL數據庫,因此現在也必須以手動方式把這些文件鏈接過來。

    [root@linuxprobe mysql]# mkdir /var/lib/mysql
    [root@linuxprobe mysql]# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
    [root@linuxprobe mysql]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
    [root@linuxprobe mysql]# ln -s /usr/local/mysql/include/mysql /usr/include/mysql

現在,MySQL數據庫服務程序已經啟動,調用的各個函數文件已經就位,PATH環(huán)境變量中也加入了MySQL數據庫命令的所在目錄。接下來準備對MySQL數據庫進行初始化,這個初始化的配置過程與MariaDB數據庫是一樣的,只是最后變成了Thanks for using MySQL!

    [root@linuxprobe mysql]# mysql_secure_installation 
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    Enter current password for root (enter for none): 此處只需按下回車鍵
    OK, successfully used password, moving on...
    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.
    Set root password? [Y/n] y (要為root管理員設置數據庫的密碼)
    New password: 輸入要為root管理員設置的數據庫密碼
    Re-enter new password: 再輸入一次密碼
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    By default, a MySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    Remove anonymous users? [Y/n] y (刪除匿名賬戶)
     ... Success!
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    Disallow root login remotely? [Y/n] y (禁止root管理員從遠程登錄)
     ... Success!
    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    Remove test database and access to it? [Y/n] y (刪除test數據庫并取消對其的訪問權限)
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    Reload privilege tables now? [Y/n] y (刷新授權表,讓初始化后的設定立即生效)
     ... Success!
    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.
    Thanks for using MySQL!
    Cleaning up...

網站標題:創(chuàng)新互聯linux教程:20.2.1配置Mysql服務
文章網址:http://www.5511xx.com/article/cosspji.html