1、首先下載MySQL的安裝檔案,我這裡安裝的是MySQL5.1.7版本的,
下載連結:http://pan.baidu.com/share/link?shareid=255483056&uk=924063144
http://pan.baidu.com/share/link?shareid=269901909&uk=924063144
2、安裝MySQL資料庫伺服器
進入安裝包所在檔案夾,執行命令 rpm -ivh MySQL-server-5.1.7-0.i386.rpm 安裝MySQL伺服器。
如果報了與原先版本衝突的話,就執行rpm -qa|grep -i mysql命令,會顯示已安裝的Mysql版本,我的顯示mysql-libs-5.1.61-4.el6.i686
這時如果有的話就強制移除:rpm -e --nodeps mysql-libs-5.1.61-4.el6.i686(因為有包依賴,所以要強制移除)
我的報錯提示如下:
MySQL-server-5.1.7-0100%/usr/share/mysql/charsets/README from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4/usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.1.7-0.i386.rpm conflicts with file from mysql-libs-5.1.61-4.el6.i686
這時候再執行rpm -ivh MySQL-server-5.1.7-0.i386.rpm安裝即可安裝成功。
我這裡安裝成功了,但是mysql服務無法啟動,總是啟動失敗,後來百度了一下,是因為selinux的原因,只要將selinux關閉就OK了。
關閉selinux:vi /etc/selinux/config 將SELINUX=enforcing 改成SELINUX=disabled 然後重啟
關閉selinux之後還是無法啟動mysql服務,因為安裝的mysql所有者是root,在安裝mysql的時候會建立一個使用者mysql,只要將/var/lib/mysql
的所有者改為mysql就OK了,執行命令chown -R mysql:mysql /var/lib/mysql
現在執行service mysql start終於可以啟動mysql服務了。
3.安裝MySQL用戶端
執行命令rpm -ivh MySQL-client-5.1.7-0.i386.rpm進行安裝。
4.安裝成功
成功安裝MySQL後將sql檔案匯入到資料庫,步驟如下:
進入MYSQL Command Line Client
1、先建立資料庫:create database test 註:test是建立資料庫的名稱
2、再切換到當前資料庫:use test
3、再輸入:\. /root/test.sql 或 souce /root/test.sql
按照以上步驟就可以將備份的sql指令碼匯入到linux中的資料庫中去。