MySQL啟動時必需到usr/local/mysql目錄的問題解決方案

來源:互聯網
上載者:User

標籤:some   port   5.5   sql資料庫   配置   run   步驟   這一   medium   

之前我安裝MySql資料庫的時候,由於我的MySQL不是安裝在標準的/usr/local/mysql目錄,而是安裝在/usr/local/development/mysql-5.5.25目錄,導致在啟動MySQL服務時報告找不到/usr/local/mysql目錄的錯誤。最後我就建立了符號鏈/usr/local/mysql連結到/usr/local/development/mysql-5.5.25,解決了服務啟動不了的問題。

為什麼會出現此問題呢?我們可以開啟mysql.server指令檔,裡面有這樣的代碼:

# If you install MySQL on some other places than /usr/local/mysql, then you# have to do one of the following things for this script to work:## - Run this script from within the MySQL installation directory# - Create a /etc/my.cnf file with the following information:#   [mysqld]#   basedir=<path-to-mysql-installation-directory># - Add the above to any other configuration file (for example ~/.my.ini)#   and copy my_print_defaults to /usr/bin# - Add the path to the mysql-installation-directory to the basedir variable#   below.## If you want to affect other MySQL variables, you should make your changes# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.# If you change base dir, you must also change datadir. These may get# overwritten by settings in the MySQL configuration files.basedir=datadir=# The following variables are only set for letting mysql.server find things.# Set some defaultsmysqld_pid_file_path=if test -z "$basedir"then  basedir=/usr/local/mysql  bindir=/usr/local/mysql/bin  if test -z "$datadir"  then    datadir=/usr/local/mysql/data  fi  sbindir=/usr/local/mysql/bin  libexecdir=/usr/local/mysql/binelse  bindir="$basedir/bin"  if test -z "$datadir"  then    datadir="$basedir/data"  fi  sbindir="$basedir/sbin"  libexecdir="$basedir/libexec"fi

也就是說,/usr/local/mysql目錄是它的預設安裝目錄。要解決此問題,需要有兩個步驟。

步驟一:建立/etc/my.cnf檔案,裡麵包含basedir目錄設定。

cd /usr/local/development/mysql-5.5.25/support-filessudo cp my-medium.cnf my.cnfcd /etcsudo ln -s /usr/local/development/mysql-5.5.25/support-files/my.cnf

然後將basedir=/usr/local/development/mysql-5.5.25這一條指令放到my.cnf檔案的mysqld段。

# The MySQL server[mysqld]......basedir=/usr/local/development/mysql-5.5.25

步驟二:將mysql目錄下的bin/my_print_defaults連結到/usr/bin目錄下。

cd /usr/binsudo ln -s /usr/local/development/mysql-5.5.25/bin/my_print_defaults

為什麼需要my_print_defaults呢?這是因為mysql.server執行時就是通過my_print_defaults來讀取my.cnf組態變數的。

完成上面兩個步驟後,刪除/usr/local/mysql,也應該是可以正常啟動和停止mysql服務的。

MySQL啟動時必需到usr/local/mysql目錄的問題解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.