linux安裝mysql 5.5並修改其安裝路徑

myownstars發表於2011-07-20

 

檢視OS版本

[root@justin mysqldata]# more /etc/issue

Enterprise Linux Enterprise Linux AS release 4 (October Update 8)

 

解除安裝了已有的mysql

首先執行yum remove mysql

然後透過rpm –qa | grep mysql檢視是否還有殘餘的Mysql外掛,若有則透過以下命令刪除

[root@justin oracle]# rpm -e mysqlclient10-3.23.58-4.RHEL4.1

error: "mysqlclient10-3.23.58-4.RHEL4.1" specifies multiple packages

[root@justin oracle]# rpm -e --allmatches mysqlclient10-3.23.58-4.RHEL4.1

error: Failed dependencies:

        libmysqlclient.so.10()(64bit) is needed by (installed) MyODBC-2.50.39-25.RHEL4.1.x86_64

        libmysqlclient.so.10()(64bit) is needed by (installed) qt-MySQL-3.3.3-16.el4.x86_64

[root@justin oracle]# rpm -e  MyODBC-2.50.39-25.RHEL4.1.x86_64

[root@justin oracle]# rpm -e qt-MySQL-3.3.3-16.el4.x86_64

[root@justin oracle]# rpm -e --allmatches mysqlclient10-3.23.58-4.RHEL4.1

[root@justin oracle]# rpm -qa | grep mysql

 

 

安裝MySQL-server-5.5.14-1.rhel5.x86_64.rpm一直報告缺失相應patch

[root@justin oracle]# rpm -ivh MySQL-server-5.5.14-1.rhel5.x86_64.rpm

warning: MySQL-server-5.5.14-1.rhel5.x86_64.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

error: Failed dependencies:

        libc.so.6(GLIBC_2.4)(64bit) is needed by MySQL-server-5.5.14-1.rhel5.x86_64

        rtld(GNU_HASH) is needed by MySQL-server-5.5.14-1.rhel5.x86_64

嘗試yum install libc.so.6卻又不成功,於是改為安裝MySQL-server-5.5.14-1.linux2.6.x86_64.rpmMySQL-client-5.5.14-1.linux2.6.x86_64.rpm,然而安裝的時候卻又遇到以下錯誤。

[root@justin oracle]# rpm -ivh MySQL-server-5.1.51-1.glibc23.x86_64.rpm

warning: MySQL-server-5.1.51-1.glibc23.x86_64.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

Preparing...                ########################################### [100%]

   1:MySQL-server           ########################################### [100%]

ERROR: 1136  Column count doesn't match value count at row 1

110719 18:08:15 [ERROR] Aborting

 

110719 18:08:15 [Note] /usr/sbin/mysqld: Shutdown complete

 

 

Installation of system tables failed!  Examine the logs in

/var/lib/mysql for more information.

 

You can try to start the mysqld daemon with:

 

    shell> /usr/sbin/mysqld --skip-grant &

 

and use the command line tool /usr/bin/mysql

to connect to the mysql database and look at the grant tables:

 

    shell> /usr/bin/mysql -u root mysql

    mysql> show tables

 

Try 'mysqld --help' if you have problems with paths.  Using --log

gives you a log in /var/lib/mysql that may be helpful.

 

Please consult the MySQL manual section

'Problems running mysql_install_db', and the manual section that

describes problems on your OS.  Another information source are the

MySQL email archives available at

 

Please check all of the above before mailing us!  And remember, if

you do mail us, you MUST use the /usr/bin/mysqlbug script!

 

費了一大堆力氣,最後找到答案,原來的mysql資訊沒有解除安裝乾淨,只需要移除/var/lib/mysql即可解決。

 

透過rpm –ivh 先後安裝MySQL-server-5.5.14-1.linux2.6.x86_64.rpmMySQL-client-5.5.14-1.linux2.6.x86_64.rpm.

Mysql預設安裝路徑為根目錄,而61上的根目錄空間有限,需將其轉移的/data目錄

[root@justin oracle]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              20G   15G  4.5G  77% /

/dev/sda1             289M   25M  250M  10% /boot

/dev/sda5             681G  213G  434G  33% /data

none                   63G     0   63G   0% /dev/shm

 

首先在/data目錄下建立名為mysqldata的目錄,然後chown –R  mysql /data/mysqldata  chgrp –R mysql /data/mysqldata 將其屬主設定成mysql

然後停止mysql服務,執行service mysql stop

/var/lib/mysql目錄下所有的檔案遷移到新建立的/data/myqldata下,mv  /var/lib/mysql  /data/mysqldata

修改配置檔案/etc/my.conf

#socket         = /var/lib/mysql/mysql.sock—修改前

socket = /data/mysqldata/mysql/mysql.sock—修改後的值

修改/etc/rc.d/init.d/mysql

  if test -z "$datadir"

   #datadir=/var/lib/mysql—修改前的值

   datadir=/data/mysqldata/mysql—修改後的值

儲存並退出

 

此時重啟service mysql start,雖然能啟動成功,卻多出一條警告資訊

[root@justin mysqldata]# service mysql start

/etc/init.d/mysql: line 71: /data/mysqldata/mysql: is a directory

Starting MySQL..[  OK  ]

 

經查實,檔案/etc/rc.d/init.d/myql中的記錄 datadir=/data/mysqldata/mysql 等號後面多出一個空格,去除即可

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15480802/viewspace-702671/,如需轉載,請註明出處,否則將追究法律責任。

相關文章