第一次在Linux(Ubuntu 10.10)上安裝MySQL,還是費了一些周折,總算基本理清思路了。先說說我最終成功安裝的步驟,即在Ubuntu 10.10裡下載mysql源碼,編譯安裝。
當前mysql版本是5.5.20,我的系統版本是ubuntu 10.10
1下載源碼:
在官方網站,
選擇:MySQL Community Server--download
選擇 sourcecode,前面幾個都是什麼rpm,最後一個是我覺得應該下載的包
Generic Linux (Architecture Independent), Compressed TAR Archive |
|
5.5.20 |
23.2M |
Download |
(mysql-5.5.20.tar.gz) |
2下載完成,解壓縮。
裡面有個安裝說明檔案:INSTALL-SOURCE
開啟,裡面這一段是核心安裝步驟:(命令前都加sudo執行!)
# Preconfiguration setup 首先是添加一個使用者組
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz 解壓縮源碼包
shell> cd mysql-VERSION 切換到源碼包目錄
shell> cmake . 執行cmake,產生mk檔案(沒有cmake,sudo apt-get install cmake)
shell> make 編輯
shell> make install 安裝
# End of source-build specific instructions -----------ok,安裝完成了哦
# Postinstallation setup ----下面是配置mysql
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql ---執行內部mysql安裝(參看紅線下方執行結果)
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional --字面意思:下面這個命令可選
shell> cp support-files/my-medium.cnf /etc/my.cnf 複製mysql設定檔
shell> bin/mysqld_safe --user=mysql & 啟動資料庫
# Next command is optional --字面意思:下面這個命令可選
shell> cp support-files/mysql.server /etc/init.d/mysql.server 設定自啟動
按照這個就能完整安裝了
3安裝完並且配置完,進去看一下
在/usr/local/mysql 目錄,執行
root@ www.bkjia.com -laptop:/usr/local/mysql# ./bin/mysql -u root -S /tmp/mysql.sock -p
正常登入,提示:
- Server version: 5.5.20-log Source distribution
-
- Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
-
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
-
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
- mysql>
4官方網站有個gui工具,可以下載試一下:
MySQL Workbench (GUI Tool)