CentOS 6.5下安裝MySQL 5.6.21

來源:互聯網
上載者:User

CentOS 6.5下安裝MySQL 5.6.21
MySQL安裝

Linux中使用最廣泛的資料庫就是MySQL,使用線上yum的方式安裝的版本落後MySQL網站好幾個小版本,本節親自測試安裝新版的MySQL。

測試機器環境:

VMware Workstation 10 虛擬機器

記憶體:1G

Linux版本:CentOS MinimalCD 6.5

JAVA:JAVA_HOME=/opt/jdk

安裝mysql前需要查詢系統中含有的有關mysql的軟體。

rpm -qa | grep -i mysql  //grep -i是不分大小寫字元查詢,只要含有mysql就顯示

螢幕顯示:

mysql-libs-5.1.71-1.el6.i686  //它是好幾個軟體的依賴,其中在mini版本中postfix軟體依賴mysql-libs,網路上很多建議都是直接刪除,yum remove mysql-libs 或者 rpm -e --nodeps mysql-libs-5.1.71-1.el6.i686,總覺得這樣做不好。
尋找mysql官方資料,得到安裝方法是用MySQL-shared-compat將mysql-libs-5.1.71-1.el6.i686替換為同版本後在安裝mysql。

下載mysql地址:http://dev.mysql.com/downloads/mysql/

CentOS是RedHatLinux系列的,因此選擇RedHatLinux(見紅線地方),網頁會自動變成RedHatLinux有關的mysql下載:

需要下載2個內容,一個是MySQL-5.6.21-1.el6.i686.rpm-bundle.tar,這個是幾個程式的合集包,另一個是MySQL-shared-compat-5.6.21-1.el6.i686.rpm,這個是軟體包包括MySQL 3.23和MySQL 4.0的共用庫。如果你安裝了應用程式動態串連MySQL 3.23,但是你想要升級到ySQL 4.0而不想打破庫的從屬關係,則安裝該軟體包而不要安裝MySQL-shared。從MySQL 4.0.13起包含該安裝軟體包。

將2個檔案上傳到CentOS中,解壓MySQL-5.6.21-1.el6.i686.rpm-bundle.tar。

 
#tar xvf MySQL-5.6.21-1.el6.i686.rpm-bundle.tar MySQL-client-5.6.21-1.el6.i686.rpmMySQL-devel-5.6.21-1.el6.i686.rpmMySQL-shared-5.6.21-1.el6.i686.rpmMySQL-test-5.6.21-1.el6.i686.rpmMySQL-server-5.6.21-1.el6.i686.rpmMySQL-embedded-5.6.21-1.el6.i686.rpm#ls -ltotal 415068-rw-r--r--. 1 root root  210442240 Nov 11 11:12 MySQL-5.6.21-1.el6.i686.rpm-bundle.tar-rw-r--r--. 1 7155 wheel  17813608 Sep 12 16:25 MySQL-client-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel   3131328 Sep 12 16:25 MySQL-devel-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel  83106000 Sep 12 16:25 MySQL-embedded-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel  54611632 Sep 12 16:26 MySQL-server-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel   1878756 Sep 12 16:27 MySQL-shared-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 root root    4141488 Nov 18 14:42 MySQL-shared-compat-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel  49887932 Sep 12 16:27 MySQL-test-5.6.21-1.el6.i686.rpm
 

安裝MySQL-shared-compat替換mysql-libs,如果不替換,在刪除mysql-libs,會提示postfix依賴於mysql-libs:

# rpm -i MySQL-shared-compat-5.6.21-1.el6.i686.rpm# rpm -qa | grep -i mysqlmysql-libs-5.1.71-1.el6.i686MySQL-shared-compat-5.6.21-1.el6.i686# yum remove mysql-libs

測試MySQL-server安裝,提示需要安裝perl:

# rpm -ivh --test MySQL-server-5.6.21-1.el6.i686.rpm# yum install perl

安裝MySQL-server,MySQL-client:

 
# rpm -ivh  MySQL-server-5.6.21-1.el6.i686.rpmPreparing...                ########################################### [100%]   1:MySQL-server           ########################################### [100%]………………………………A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !You will find that password in '/root/.mysql_secret'.You must change that password on your first connect,no other statement but 'SET PASSWORD' will be accepted.See the manual for the semantics of the 'password expired' flag.Also, the account for the anonymous user has been removed.In addition, you can run:  /usr/bin/mysql_secure_installation………………………………# rpm -ivh  MySQL-client-5.6.21-1.el6.i686.rpmPreparing...                ########################################### [100%]   1:MySQL-client           ########################################### [100%]
 

在安裝MySQL-server,見上面的一段話,大意是全新安裝設定的root密碼在/root/.mysql_secret中,這是一個隨機密碼,你需要運行/usr/bin/mysql_secure_installation,刪除anonymous使用者。當然不建議用root使用者來運行,rpm包已經建了一個mysql使用者,可以使用這個使用者:

 
#more .mysql_secret# The random password set for the root user at Tue Nov 18 22:57:46 2014 (local time): NljqL63OYlGo5cqy    <– 得到root訪問mysql的密碼:NljqL63OYlGo5cqy# service mysql startStarting MySQL... SUCCESS! # /usr/bin/mysql_secure_installation --user=mysqlNOTE: 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 currentpassword for the root user.  If you've just installed MySQL, andyou 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):    <–使用剛才得到的root的密碼 NljqL63OYlGo5cqyOK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.You already have a root password set, so you can safely answer 'n'.Change the root password? [Y/n] y   <– 是否更換root使用者密碼,輸入y並斷行符號,強烈建議更換New password:      <– 設定root使用者的密碼Re-enter new password:    <– 再輸入一次你設定的密碼Password updated successfully!Reloading privilege tables.. ... Success!By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y   <– 是否刪除匿名使用者,生產環境建議刪除,所以輸入y並斷行符號 ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y    <–是否禁止root遠程登入,根據自己的需求選擇Y/n並斷行符號,建議禁止 ... Success!By default, MySQL comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y    <– 是否刪除test資料庫,輸入y並斷行符號 - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y   是否重新載入許可權表,輸入y並斷行符號 ... Success!All done!  If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!Cleaning up...
 

至此,MySQL已經安裝完成,最後看一下是否已將MySQL加到開機服務裡:

 
#  chkconfigauditd          0:off   1:off   2:on    3:on    4:on    5:on    6:offblk-availability        0:off   1:on    2:on    3:on    4:on    5:on    6:offcrond           0:off   1:off   2:on    3:on    4:on    5:on    6:offip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:offiptables        0:off   1:off   2:on    3:on    4:on    5:on    6:offiscsi           0:off   1:off   2:off   3:on    4:on    5:on    6:offiscsid          0:off   1:off   2:off   3:on    4:on    5:on    6:offlvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:offmdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:offmultipathd      0:off   1:off   2:off   3:off   4:off   5:off   6:offmysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off   <-看到這個OK了netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:offnetfs           0:off   1:off   2:off   3:on    4:on    5:on    6:offnetwork         0:off   1:off   2:on    3:on    4:on    5:on    6:offpostfix         0:off   1:off   2:on    3:on    4:on    5:on    6:offrdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:offrestorecond     0:off   1:off   2:off   3:off   4:off   5:off   6:offrsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:offsaslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:offsshd            0:off   1:off   2:on    3:on    4:on    5:on    6:offudev-post       0:off   1:on    2:on    3:on    4:on    5:on    6:off
 

MySQL安裝後涉及的目錄如下:

目錄 目錄中的內容
/usr/bin 用戶端程式和指令碼
/usr/sbin Mysqld伺服器
/var/lib/mysql 資料庫的記錄檔
/usr/share/info 資訊格式手冊
/usr/share/man Unix 手冊頁
/usr/include/mysql 包括 (標題) 的檔案
/usr/lib/mysql mysql的lib包
/usr/share/mysql 雜項的支援檔案,包括錯誤訊息) 字元設定的檔案,樣本設定檔,SQL 資料庫安裝
/usr/share/sql-bench 基準

現在好了,可以測試你的MySQL了。

--------------------------------------分割線 --------------------------------------

Ubuntu 14.04下安裝MySQL

《MySQL權威指南(原書第2版)》清晰中文掃描版 PDF

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主從伺服器

Ubuntu 12.04 LTS 構建高可用分布式 MySQL 叢集

Ubuntu 12.04下原始碼安裝MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二進位安裝

--------------------------------------分割線 --------------------------------------

本文永久更新連結地址: 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.