mysql在windows下的編譯和調(diào)試(vs2008)
環(huán)境準(zhǔn)備
1.下載mysql源代碼:http://dev.mysql.com/downloads/mysql/#downloads 這里最新的版本是5.5.23
如下:

2.安裝CMake
下載地址:http://www.cmake.org/cmake/resources/software.html 編譯器, 記得Linux下的 make么, 沒錯(cuò)這個(gè)就是他哥,進(jìn)階版。
3.安裝GNUWin32 Bison
下載地址為:http://gnuwin32.sourceforge.net/packages/bison.htm, 同樣安裝路徑最好為英文,并且不要有空格。安裝后將bin路徑添加到系統(tǒng)環(huán)境變量。
編譯
進(jìn)入mysql的根目錄下,輸入cmake . -G "Visual Studio 9 2008",正常的話會(huì)有XXX done什么的
成功的話會(huì)有MySQL.sln和一大堆.vcproj文件,打開MySQL.sln,就可以看到整個(gè)解決方案
在編譯之前,建議打開sql/sql_locale.cc文件,將其用utf-8格式再保存一遍,不然編譯過程當(dāng)中會(huì)有大量錯(cuò)誤。
應(yīng)該就可以編譯成功。
到sql/debug 下執(zhí)行
mysqld-debug --debug –-standalone
應(yīng)該會(huì)出現(xiàn)錯(cuò)誤,提示你mysqld.cc中的某個(gè)斷言有問題,把那段注解掉重新編譯。
編譯完以后繼續(xù)
mysqld-debug --debug –-standalone
發(fā)現(xiàn)還是起不來mysqld的進(jìn)程。
查看log文件
mysqld.exe: Table 'mysql.plugin' doesn't exist
120414 11:34:08 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120414 11:34:08 InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!
120414 11:34:08 InnoDB: The InnoDB memory heap is disabled
120414 11:34:08 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120414 11:34:08 InnoDB: Compressed tables use zlib 1.2.3
120414 11:34:08 InnoDB: Initializing buffer pool, size = 128.0M
120414 11:34:08 InnoDB: Completed initialization of buffer pool
120414 11:34:08 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
120414 11:34:08 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
120414 11:34:09 InnoDB: Waiting for the background threads to start
120414 11:34:10 InnoDB: 1.1.8 started; log sequence number 1595675
120414 11:34:10 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
意思是mysl下的表沒有建立,很奇怪這個(gè)不知道是什么原因,我是到別的地方拷貝了mysql下的文件放到sql/data/mysql下

如果沒有什么意外
執(zhí)行
mysqld-debug --debug –-standalone
就可以建立啟動(dòng)mysqld進(jìn)程了。
使用vs2008進(jìn)行調(diào)試
測試---》附加到進(jìn)程

選擇mysqld
定位到 \client\Debug,執(zhí)行命令“mysql -u root -p”,進(jìn)入mysql客戶端,
在這邊下斷點(diǎn):

在mysql 客戶端下:
show authors;

就可以進(jìn)入斷點(diǎn)進(jìn)行調(diào)試:

參考地址:
http://qa.taobao.com/?p=9699
http://likydba.sinaapp.com/?p=578
http://www.cnblogs.com/yuemenglong/archive/2011/06/14/2080262.html
posted on 2012-04-15 10:37
漂漂 閱讀(2930)
評(píng)論(0) 編輯 收藏 引用