第一次在linux上安裝mysql,還是費了一些周折,總算基本理清思路了。
先說說我最終成功安裝的步驟,即:下載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 | |
(mysql-5.5.20.tar.gz) |
裏面有個安裝說明文件: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@cheng-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工具,可以下載試一下:
5其他就是創建鏈接或者環境變量,實現在終端中,直接執行mysql........
這個網上很多,自己蒐集吧
-------------------------------------------------------------------------------------------------------------
(執行內部mysql安裝結果)
cheng@cheng-laptop:/usr/local/mysql$
sudo scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
(要設置開機自啓動,請將文件複製到系統正確的地方)
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
(記得給mysql管理員設置密碼)
To do so, start the server, then issue the following commands:(設置密碼方式1)
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h cheng-laptop password 'new-password'
Alternatively you can run:(或者你可以運行下面這個命令進行密碼設置,我用的這個,裏面其實不只是設置root密碼)
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:(運行MySQL daemon,需要cd到當前目錄,執行./bin/mysqld_safe &)
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
cheng@cheng-laptop:/usr/local/mysql$
------------------------------------------------------------------------------------------------------
其他:
1關於ubuntu安裝版本,官網
》》》》》MySQL Community Server--Debian Linux ,
MySQL Community Server--generic,最後一個
Linux - Generic 2.6 (x86, 64-bit), Compressed TAR Archive | 5.5.20 | 177.3M | ||
(mysql-5.5.20-linux2.6-x86_64.tar.gz) |