2012年9月18日 星期二

Git and Gerrit installation

this memo references following url:
http://scmforge.com/?p=1
http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup
http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson

also based on my trial to setup gerri,git on 64 bit ubuntu server as guest OS of vmware virtual machine runs on 64 bit win 7 host OS

First step – Git installation:

As I use Ubuntu – this task is very simple. Just run one command like below:
root@scmforge:~# sudo apt-get -y install git-core
and verify installation:
root@scmforge:~# git --version
git version 1.7.5.4

git setup:
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

Second step – Gerrit installation:

I prefer to use functional accounts for each of services on my servers so first I create gerrit user:
root@scmforge:~# adduser gerrit
root@scmforge:~# su - gerrit
gerrit@scmforge:~$

To build Gerrit war package – Maven and some Java JDK is necessary as Gerrit is Java based tool, in my case I used the following command to install both:
root@scmforge:~# apt-get install maven2 openjdk-6-jdk
After gerrit user is already created and all prerequisites to build and run Gerrit are installed – now is the time to get Gerrit sources and prepare executable package:
root@scmforge:~# su - gerrit
wget
http://gerrit.googlecode.com/files/gerrit-2.4.2.war
gerrit@scmforge:~$ git clone https://gerrit.googlesource.com/gerrit
Cloning into gerrit...
remote: Counting objects: 60865, done
remote: Finding sources: 100% (60865/60865)
remote: Getting sizes: 100% (22864/22864)
remote: Compressing objects: 100% (22858/22858)
remote: Total 60865 (delta 34139), reused 60677 (delta 34056)
Receiving objects: 100% (60865/60865), 11.74 MiB | 4.36 MiB/s, done.
Resolving deltas: 100% (34237/34237), done.
gerrit@scmforge:~$ cd gerrit/
gerrit@scmforge:~/gerrit$ mvn package

When Maven finished building, WAR file was created in gerrit-war/target/ directory, in my case it was exactly: ./target/gerrit-2.3.war

Some database will be needed (MySQL, PostgreSQL, or simple H2 can be used) so we can create it as usually, by:
postgres=# CREATE ROLE gerrit LOGIN ENCRYPTED PASSWORD 'gerrit' NOINHERIT VALID UNTIL 'infinity';
CREATE ROLE
postgres=# CREATE DATABASE gerrit_playground WITH ENCODING='UTF8' OWNER=gerrit;
CREATE DATABASE


Third step – creating Gerrit environment:

Now we can create playground environment by invoking Gerrit with init parameter and answering few simple questions:
gerrit@scmforge:~$ java -jar gerrit-2.3.war init -d playground
java -jar /home/gerrit/gerrit-2.4.2.war init -d playground
 *** Gerrit Code Review 2.3
Create '/home/gerrit/playground' [Y/n]? Y
*** Git Repositories
Location of Git repositories [git]: git
*** SQL Database
Database server type [H2/?]: H2

mysql
*** User Authentication
Authentication method [OPENID/?]: development_become_any_account
*** Email Delivery
SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [NONE/?]:
SMTP username :
*** Container Process
Run as [gerrit]: gerit
Java runtime [/usr/lib/jvm/java-6-openjdk/jre]: /usr/lib/jvm/java-6-openjdk/jre
Copy gerrit.war to /home/gerrit/playground/bin/gerrit.war [Y/n]?
Copying gerrit.war to /home/gerrit/playground/bin/gerrit.war
*** SSH Daemon
Listen on address [*]: *
Listen on port [29418]: 29418
Gerrit Code Review is not shipped with Bouncy Castle Crypto v144
If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]?
Downloading http://www.bouncycastle.org/download/bcprov-jdk16-144.jar ... OK
Checksum bcprov-jdk16-144.jar OK
Generating SSH host key ... rsa... dsa... done
*** HTTP Daemon
Behind reverse proxy [y/N]? N
Use SSL (https://) [y/N]? N
Listen on address [*]: *
Listen on port [8080]: 8080
Initialized /home/gerrit/playground
Executing /home/gerrit/playground/bin/gerrit.sh start

/home/gerrit/gerrit/playground/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server to start ... OK
Opening browser ...
Please open a browser and go to http://scmforge.com:8080/#/admin/projects/

g.s:8080/#/admin/projects/
As I had some serious issues with PostgreSQL connection I chose H2 as backbone database because it was the fastest workaround in my case and I do not need nothing more right now.
After opening suggested URL – I could see the following screen:

Become option allows You to create admin user account and look around at all Gerrit functionality (which is not integrated with Git yet). After that You can create Your fist Sandbox project with default settings proposed by Gerrit.
Remember to add Your SSH public key to Your account/settings – without it working with Gerrit is not possible. In Your settings You have to also specify Your Username. (which is actually SSH user)
If all setup is ok, You should be able to see similar server response after trying to log in:
szwed@vaio:~$ ssh -p 29418 szwed@scmforge.com
ssh -p 29418 d68fbe50@g.s
**** Welcome to Gerrit Code Review ****
Hi Piotr Szwed, you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://szwed@scmforge.com:29418/REPOSITORY_NAME.git
Connection to scmforge.com closed.

If You have similar results – it means that basic setup is OK and We can jump to the further steps.


Fourth step – Gerrit integration with GIT:

So.. We have already Gerrit setup and working, We have already created first project, our SSH connection is working well – now is the time to clone Sandbox repository and make some test commit. I tried the following waycd
szwed@vaio:~$ git clone ssh://szwed@scmforge.com:29418/Sandbox.git
git clone ssh://d68fbe50@g.s:29418/symfonyproject.git
Cloning into 'Sandbox'...
remote: Counting objects: 2, done
remote: Finding sources: 100% (2/2)
remote: Total 2 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2/2), done.
szwed@vaio:~$ cd Sandbox/

cd symfonyproject
szwed@vaio:~/Sandbox$ echo "Test text." > test.txt
cp -r Symfony/* symfonyproject/
szwed@vaio:~/Sandbox$ git add test.txt

git add .
szwed@vaio:~/Sandbox$ git commit -a -m "First test commit."

git commit -m 'initial symfony project version'
[master 44ca585] First test commit.
Committer: Piotr Szwed <szwed@vaio.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
1 file changed, 1 insertion(+)
create mode 100644 test.txt


create a group for your project

go to
g.s:8080/#/admin/projects/
click admin
click groups
click hyperlink  Create New Group 
enter the name of your project.
e.g.:
symfonyproject
 


give this group with push permission of your project

go to
g.s:8080/#/admin/projects/
click on projects
click on list
click on hyperlink with name of your project
click access
click edit
click on Add Reference
click on drop down menu with text:Add permission
click on push in that menu
enter the name of group you create
e.g.:
symfonyproject
click add
click Save changes




And push our changes to the Gerrit server:

szwed@vaio:~/Sandbox$ git push ssh://szwed@scmforge.com:29418/Sandbox.git 
git push ssh://d68fbe50@g.s:29418/symfonyproject.git
HEAD:refs/for/master
Counting objects: 4, done.
Writing objects: 100% (3/3), 256 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://szwed@scmforge.com:29418/Sandbox.git
* [new branch] HEAD -> refs/for/master
szwed@vaio:~/Sandbox$

After that my change was ready for review as on the picture presented below:

As a result I am able to review and approve the change. Some simple Project groups and access modifications may be needed here as by default Gerrit does not provide useful setup and Workflow.
Now is the time to invite developers and encourage Them to use Gerrit

上述的推送,沒有經過 code review 的流程


採用 code review 流程的推送方式,

需經過以下設定後推送,

 「 Gerrit不希望我們直接覆寫Git代碼庫中的任何分支,而是將變更推送到另一個refspec中,這讓Gerrit有機會在代碼審查中修改代碼。最簡單的方法是為推送配置一個默認的refspec:

$ git config remote.origin.push refs/heads/*:refs/for/*
$ git push origin


前段引文,引用自 URL :
http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson

git 介紹、指令(含 branch merge)─寫給大家的 Git 教學


http://www.slideshare.net/littlebtc/git-5528339

git pull origin

http://littleb.tc/slides/2012/everyone/git.html

「現狀紀錄」稱之為 Commit

  • git fetch:將 Remote 更新到最新的版本。
  • git pull:進行 Fetch 後,將 Remote Branch 的變動合併進本機的 Branch
  • git push:將本機的 Branch 變動合併到 Remote Branch。

First-Time Git Setup


this article reference following url:
http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup

First-Time Git Setup

Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. You should have to do these things only once; they’ll stick around between upgrades. You can also change them at any time by running through the commands again.
Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places:
  • /etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option--system to git config, it reads and writes from this file specifically.
  • ~/.gitconfig file: Specific to your user. You can make Git read and write to this file specifically by passing the --global option.
  • config file in the git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository. Each level overrides values in the previous level, so values in .git/config trump those in /etc/gitconfig.
On Windows systems, Git looks for the .gitconfig file in the $HOME directory (C:\Documents and Settings\$USER for most people). It also still looks for /etc/gitconfig, although it’s relative to the MSys root, which is wherever you decide to install Git on your Windows system when you run the installer.

Your Identity

The first thing you should do when you install Git is to set your user name and e-mail address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you pass around:
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
Again, you need to do this only once if you pass the --global option, because then Git will always use that information for anything you do on that system. If you want to override this with a different name or e-mail address for specific projects, you can run the command without the --global option when you’re in that project

git 資料轉移至 gerrit server

舊有的 git 資料,
如欲增加 code review 機制,要採用 gerrit 作為 code review server 時,
需進行以下設定後,
方可將舊有 git 資料傳至 gerrit server

新增 project

可透過 gerrit server 提供的網頁介面
(example url:
http://g.s:8080/#/admin/projects/
)
新增 project (e.g.:fromsvn)

給予上傳者 permission

以 gerrit server 提供的網頁介面,給予上傳者所屬的 group (e.g.:Administrators)如下的permission:

Reference:
refs/heads/*

Push Exclusive



Reference:
refs/*

Create Reference Exclusive

Forge Committer Identity Exclusive

git 須設定 remote


git remote add test_git ssh://g.s:29418/fromsvn.git

push to gerrit


http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson

Git、Gerrit與Jenkins/Hudson CI服務器

作者 Alex Blewitt 譯者 丁雪豐 發佈於 2011年9月6日
領域
過程 & 實踐,
語言 & 開發
主題
團隊協作 ,
Java ,
協作 ,
分佈式團隊 ,
團隊工作 ,
敏捷
本文講述了如何為基於團隊的代碼審查系統配置Git、Gerrit與Jenkins/Hudson,正如我在《Git, Gerrit and Jenkins for iOS development》《Gerrit Git Review with Jenkins CI Server》演講(以及第一次提出這種做法的《Someday...》)中所倡導的那樣。 文中的範例假定你所使用的操作系統是OS X或Linux,但是如果你願意,也可以在Windows上運行它們。

配置Git

很多系統(例如Linux)已經默認提供了Git,在Git主頁也可以找到安裝程序。對於Windows用戶,最好的選擇是MsysGit。請注意,如果你安裝了Apple Developer Tools (for Xcode 4),那麼其中已經自帶Git二進制包了。如果遇到了問題,help.github.com中可以找到很多非常出色的指南。
因為所有的Git提交都帶有作者和電子郵件地址,如果你還沒有設置過這些內容,請執行以下命令進行配置:
$ git config --global user.name "Alex Blewitt"
$ git config --global user.email Alex.Blewitt@example.com
最好有一個Git代碼庫。Gerrit在初始化階段會自動掃瞄Git代碼庫,這樣做比在後期配置代碼庫容易一些,因此最好在初始化Gerrit前準備好Git代碼庫。
如果還沒有Git代碼庫,可以創建一個:
git init --bare /path/to/gits/example.git

Gerrit

可以從http://code.google.com/p/gerrit/下載到Gerrit,那是一個WAR文件。Gerrit有很好的文檔(目前的最新文檔是2.2.1,但也可用於2.1.7)和安裝指南
Gerrit在運行時需要用到數據庫(用於存儲代碼審查的信息)。目前支持的數據庫包括H2、PostgreSQL和MySQL。在沒有進行額外配置的情況下,它默認使用H2。
請注意,Gerrit 2.2.x正把項目配置、權限和其他元數據移到Git存儲中,這樣就可以通過Git進行訪問和版本控制。在2.2.x中,這個轉變會慢慢擴展到其他類型的元數據上,包含代碼評審內容。詳見2.2.0版本的發布說明
要初始化Gerrit,運行java -jar gerrit.war init -d /path/to/location會在指定路徑上安裝Gerrit運行時。
如果是在交互終端中運行的,安裝程序會提幾個問題,例如:
  • Git代碼庫的位置 [git]
  • 導入現有代碼庫 [Y/n]
  • 數據庫服務器類型 [H2/?]
  • 身份驗證方法 [OPENID/?]
  • SMTP服務器主機名 [localhost]
  • SMTP服務器端口 [(default)]
  • SMTP加密 [NONE/?]
  • SMTP用戶名
  • 以何種身份運行 [you]
  • Java運行時 [/path/to/jvm]
  • 將gerrit.war複製到/path/to/location/bin/gerrit.war [Y/n]
  • 監聽地址 [*]
  • 監聽端口 [29418]
  • 下載並安裝Bouncy Castle [Y/n]
  • 位於HTTP反向代理之後 [y/N]
  • 使用SSL [y/N]
  • 監聽地址 [*]
  • 監聽端口 [8080]
其中大部分可以保留默認值,但是有幾個需要重點關注。
  • Git代碼庫的位置要指向正確的位置。默認值是位於安裝目錄中的'git'目錄,也可以是其他不同位置(例如/var/gits等等)。應該先配置好這個路徑,因為在Gerrit啟動時它會先掃瞄該目錄來添加新項目。
  • 監聽地址對有多個地址(例如IPv4和IPv6)的主機很有用,它可以限定使用哪個地址。*表示本地主機上的任意地址。
  • 監聽端口是一個端口號。29418是默認的Gerrit SSH端口,而8080是默認的Gerrit Web端口。但是如果8080已經被別的應用程序佔用了,那麼你可能會想修改第二個端口。
  • 身份驗證方法確定了如何登錄Gerrit。如果你想掛入某個現有的身份驗證提供方(例如Google Accounts),那麼可以使用OpenID。但對測試而言(還有上面提到的範例),可以使用 development_become_any_account。鍵入?會顯示一個可用方法的列表。
Gerrit啟動後,會打開一個瀏覽器,顯示Gerrit主頁。登錄的第一個用戶將自動成為管理員;所有後續登錄的用戶都是無權限用戶。如果你選擇 了development_become_any_account,在頁面頂端會有一個Become鏈接,通過它可以進入註冊/登錄頁面。

註冊用戶

為了使用Gerrit,你需要一個賬號,生成一個SSH密鑰對。在命令行中運行 ssh-keygen -t rsa -b 2048可以生成密鑰對,將其放到你的.ssh目錄中。如果你需要更多信息,可以訪問這篇博文,這是我六年前寫的SSH密鑰相關文章。此外,GitHub 幫助頁面中也有更多相關信息。
默認文件名為id_rsa(這是私鑰)和id_rsa.pub(這是公鑰)。你只能給別人公鑰,千萬別給別人私鑰。
有了密鑰,你就可以在Gerrit中註冊新賬戶了。點擊頂部右端的「Become」鏈接,然後再點擊「New account」按鈕,輸入Git知道的名稱和電子郵件(即上面用git config配置的),這些內容要完全匹配(包括大小寫)。保存變更,然後選擇一個唯一的用戶名(填入了名稱後點擊'select username',例如demo)。
頭痛的電子郵件 就算是development_become_any_account模式,Gerrit也會給你發送電子郵件以驗證郵件地址。不通過驗證的話就無法使用該電子郵件地址,你也無法提交代碼。
我們可以很快處理掉這個問題,因此如果Gerrit目前不讓你註冊你的郵箱地址,請不用擔心。
在'add SSH public key'文本框中,添加.pub文件中的公鑰。如果你使用的是OS X,pbcopy < ~/.ssh/id_rsa.pub就可輕鬆搞定。記住要點擊「Add」保存公鑰。
點擊Continue後應該就能登錄到Gerrit的主窗口了。到目前為止一切還不錯,現在可以測試SSH的連通性了。
鍵入ssh -p 29418 demo@localhost會嘗試連接Gerrit服務器,會出現以下三者之一:
  1. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
    
    這並沒有看上去那麼糟。它只是說你的~/.ssh/known_hosts文件中有舊的密鑰。最懶的一種修複方法是刪除這個文件(這是GitHub推薦的做法)。更好的方法是找到提示出錯的那一行,把它刪了:
    Offending key in /Users/demo/.ssh/known_hosts:123
    
    你可以用任何文本編輯器來刪除known_hosts文件中的第123行。在標準UNIX配置下,可以用以下命令自動刪除:
    sed -i '' '123d' ~/.ssh/known_hosts
  2. The authenticity of host '[localhost]:29418 ([::1]:29418)' can't be established.
    RSA key fingerprint is e8:e2:fe:19:6f:e2:db:c1:05:b5:bf:a6:ad:4b:04:33.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '[localhost]:29418' (RSA) to the list of known hosts.
    Permission denied (publickey).
    
    如果看到這個消息,說明Gerrit沒有識別出你提交的任何密鑰。ssh默認會發送id_rsa,要確認它的確發送了該值,可以查看.ssh/config,文件頭上有一行IdentityFile ~/.ssh/id_rsa。可以運行ssh -v查看發送的內容:
    debug1: Next authentication method: publickey
    debug1: Trying private key: /Users/demo/.ssh/id_dsa
    debug1: Offering public key: /Users/demo/.ssh/id_rsa
    
    假設已經發送了正確的密鑰,那麼在settings - ssh public keys菜單項中檢查該密鑰是否關聯了Gerrit中的用戶。如果沒有的話點擊'Add Key'並和之前一樣粘貼公鑰。
    如果Gerrit還是說你未經身份驗證,檢查用戶名和配置頁面裡的用戶名是否一致。如果用戶名不同,試試ssh -p 29418 username@localhost。
    最後,要驗證具體的密鑰,可以運行ssh -i ~/.ssh/id_rsa顯式地選擇要使用的密鑰,而不是讓它自動選擇密鑰。如果這樣可以工作,但不帶-i參數卻不行的話,那麼問題出在你的~ /.ssh/config文件裡──你需要保證選擇了合適的IdentityFile。
  3.   ****    Welcome to Gerrit Code Review    ****
    
      Hi demo, you have successfully connected over SSH.
    
      Unfortunately, interactive shells are disabled.
      To clone a hosted Git repository, use:
    
      git clone ssh://demo@localhost:29418/REPOSITORY_NAME.git
    
    Connection to localhost closed.
    
    如果看到這個提示,說明Gerrit已經正常工作了。

修正電子郵件地址

如果之前你無法在Gerrit中註冊電子郵件地址,那麼可以手工進行註冊。我們可以停止Gerrit,運行GSQL工具更新特定數據字段。
$ bin/gerrit.sh stop
$ java -jar bin/gerrit.war gsql
Welcome to Gerrit Code Review 2.1.6.1
(H2 1.2.134 (2010-04-23))

Type '\h' for help.  Type '\r' to clear the buffer.

gerrit> select * from ACCOUNT_EXTERNAL_IDS;
 ACCOUNT_ID | EMAIL_ADDRESS          | PASSWORD | EXTERNAL_ID
 -----------+------------------------+----------+------------------------------------------
 1000000    | NULL                   | NULL     | uuid:ac1b8a08-2dd1-4aa1-8449-8b2994dffaed
 1000000    | NULL                   | NULL     | username:demo
(2 rows; 23 ms)
gerrit> update ACCOUNT_EXTERNAL_IDS set EMAIL_ADDRESS='alex.blewitt@example.com' where ACCOUNT_ID=1000000;
UPDATE 2; 5 ms
gerrit> select * from ACCOUNT_EXTERNAL_IDS;
 ACCOUNT_ID | EMAIL_ADDRESS          | PASSWORD | EXTERNAL_ID
 -----------+------------------------+----------+------------------------------------------
 1000000    | alex.blewitt@example.com | NULL     | uuid:ac1b8a08-2dd1-4aa1-8449-8b2994dffaed
 1000000    | alex.blewitt@example.com | NULL     | username:demo
(2 rows; 23 ms)
gerrit> \q
Bye
$ bin/gerrit.sh start

創建項目,克隆並推送代碼

開始前,我們需要先在Gerrit中創建一個項目。如果Gerrit沒有在你的範例目錄中檢測到項目,在它運行時,我們可以創建一個項目。
$ ssh -p 29418 demo@localhost gerrit create-project --name example.git
上述命令會創建一個名為example的項目,在之前指定的Git目錄裡初始化一個空的代碼庫。如果已經有一個代碼庫了,Gerrit不允許創建同名代碼庫——但你可以先對它進行臨時重命名,隨後再把名字改回來。
隨後,可以創建一個克隆:
$ git clone ssh://demo@localhost:29418/example.git
Cloning into example...
warning: You appear to have cloned an empty repository.
我們可以向代碼庫進行提交和推送,就和其他Git系統一樣:
$ cd example
$ echo hello > world
$ git add world
$ git commit -m "The World"
[master (root-commit) 06bf85e] The World
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 world
$ git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 217 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://me@localhost:29418/example.git
 ! [remote rejected] master -> master (prohibited by Gerrit)
error: failed to push some refs to 'ssh://demo@localhost:29418/example.git'
這是什麼情況?Gerrit不希望我們直接覆寫Git代碼庫中的任何分支,而是將變更推送到另一個refspec中,這讓Gerrit有機會在代碼審查中修改代碼。最簡單的方法是為推送配置一個默認的refspec:
$ git config remote.origin.push refs/heads/*:refs/for/*
$ git push origin
Counting objects: 3, done.
Writing objects: 100% (3/3), 217 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://demo@localhost:29418/example.git
 * [new branch]      master -> refs/for/master

gerrit OpenID authentication


192.168.200.143:8080/Documentation/access-control.html

If the Gerrit instance is configured to use OpenID authentication, an account’s effective group membership will be restricted to only the Anonymous Users and Registered Users groups, unless all of its OpenID identities match one or more of the patterns listed in the auth.trustedOpenID list from gerrit.config.

gerrit.config auth.trustedOpenID

To trust only Google Accounts:
git config --file $site_path/gerrit.config auth.trustedOpenID 'https://www.google.com/accounts/o8/id?id='

sudo git config --file /home/gerrit/playground/etc/gerrit.config auth.trustedOpenID 'https://www.google.com/accounts/o8/id?id='

mysql schema export


http://hugedream.blogspot.tw/2009/11/dump-schema.html

若要匯出MySQL下某個資料庫的Schema,可以用mysqldump來達成:

# mysqldump -d -u 使用者名稱 -p 欲備份的資料庫 >> FILENAME.sql

例:
# mysqldump -d -u howard -p account > account.sql


匯入到新的MySQL資料庫

# mysql -u 使用者名稱 -p 資料庫 < account.sql