MySQL源碼安裝完成後修改安裝路徑啓動問題

在Linux上源碼編譯安裝完mysql後,又將安裝的路徑進行了修改,可是發如今設置後環境變量後啓動報錯,以下:html

[root@HServer_03 var]# mysqld_safe --user=mysql &mysql

[1] 31248sql

[root@HServer_03 var]# 110422 11:04:00 mysqld_safe Logging to '/opt/mysql5156/var/HServer_03.err'.bash

touch: cannot touch `/opt/mysql5156/var/HServer_03.err': No such file or directoryide

chown: cannot access `/opt/mysql5156/var/HServer_03.err': No such file or directorythis

110422 11:04:00 mysqld_safe The file /opt/mysql5156/libexec/mysqldrest

does not exist or is not executable. Please cd to the mysql installationorm

directory and restart this script from there as follows:htm

./bin/mysqld_safe&ip

See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information

/usr/local/mysql/bin/mysqld_safe: line 100: /opt/mysql5156/var/HServer_03.err: No such file or directory

[1]+ Exit 1 mysqld_safe --user=mysql

按照提示原有的路徑目錄不存在,須要到mysql的相對路徑下啓動~

個人原安裝路徑是在/opt/mysql5156下,具體的安裝過程:

Shell> tar –zxvvf mysql-5.1.56.tar.gz

Shell> cd mysql-5.1.56

Shell> ./configure --prefix=/opt/mysql5156 \

--with-charset=utf8 --with-collation=utf8_general_ci \

--with-extra-charsets=latin1,gb2312 \

--with-plugins=innobase,innodb_plugin,myisam,heap,csv,federated,blackhole \

--enable-local-infile --enable-thread-safe-client

Shell> make

Shell >make install

Shell> cp support-files/my-medium.cnf /etc/my.cnf

Shell>cd /opt/mysql5156

Shell>chown –R mysql .

Shell>chgrp –R mysql .

Shell>bin/mysql_install_db –user=mysql

Shell>chown –R root .

Shell> chown –R mysql var

Shell>vi /root/.bash_profile

PATH=$PATH:$HOME/bin:/opt/mysql5156/bin

如今將/opt/mysql5156/目錄移動到/usr/local/下:

Shell>mv /opt/mysql5156 /usr/local/mysql

Shell>vi /root/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

Shell>source /root/.bash_profile

在啓動時出現上述錯誤的主要緣由是mysql在編譯安裝時,將路徑/opt/mysql5156寫入了mysql/bin/mysqld_safe腳本中,打開該腳本能夠明確看到各個啓動邏輯的判斷都有/opt/mysql5156的影子,那麼將全部的/opt/mysql5156 全局替換爲/usr/local/mysql,保存後從新啓動,ok了。

另外因爲此次的編譯安裝時採用動態編譯的,還須要修改mysql的動態函式庫,

Shell>vi /etc/ld.so.conf

/usr/local/mysql/lib/mysql/

Shell>ldconfig

這樣在新的路徑下,編譯安裝的mysql就能夠無礙使用了。

相關文章
相關標籤/搜索