Ubuntu下配置MySQL資料庫簡述

來源:互聯網
上載者:User

一). Ubuntu下MySQL安裝布局:

/usr/bin                      用戶端程式和mysql_install_db
/db                             資料庫和記錄檔(自訂的)
/var/run mysqld        伺服器
/etc/mysql mysql       設定檔my.cnf
/usr/share/mysql       字元集,基準程式和錯誤訊息
/etc/init.d/mysql        啟動mysql伺服器


二). 修改mysql資料庫檔案的儲存目錄:

假設我們指定的資料庫檔案目錄為/db
1. 建立目錄 /db,並修改其擁有者及所屬群組為mysql:mysql.命令:chown mysql:mysql db
2. 關閉mysql資料庫服務:mysqladmin -u root -p shutdown
3. 修改mysql設定檔my.cnf:將datadir=/var/lib/mysql改為datadir=/db
4. 重新初始化資料檔案:執行mysql_install_db
5. 啟動mysql資料庫服務:sudo /etc/init.d/mysql start
6. 設定mysql資料庫root密碼:mysqladmin -u root password ‘new-password’
此時我們會發現/db目錄下出現mysql相關檔案。如果我們建立資料庫,其資料庫檔案也將出現在db目錄下。表示我們修改的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.