mysql 3013_mysql5.7.13+VS3013 源代码阅读调试-Go语言中文社区

之前写Java,对C++,make,cmake都不是很熟,所以参考了以下这些前辈写的博客,最后成功搭建了mysql5.7.13+VS3013调试环境,自己总结了需要需要注意的几点。

1)一定要一切以官网说明为王道,官网说明地址,最好下载MySQL

5.7 Reference Manual,这才是MySQL最权威最全面的资料,阅读中文资料可能会有一些困惑,然后阅读MySQL参考手册可以豁然开朗,

比如(1),很多博客都要求安装Bison,但是我没有安装Bison也没有问题,MySQL5.7参考手册上说的很明白,用Standard Source Distribution来build工程不需要Bison,而用Development Source Tree才需要Bsion,从官网上直接下载的标准版的源码ZIP包就是Standard Source Distribution,而在GitHub下载的最新的开发源码就是Development

Source Tree。

(2),cmake configure可能会遇到如下图片中的错误,查看MySQL源码下的CmakeList.txt文件有“INCLUDE(cmake/boost.cmake)”,然后查看MySQL参考手册有说明,构建MySQL需要Boost libraries,但是不会用它,并给出了图片中的错误的解决方法。

Source Installation System Requirements

• The Boost C++ libraries are required to build MySQL (but not to use it). Boost 1.59.0 or higher must be installed. To obtain Boost and its installation instructions, visit the official site. After

Boost is installed, tell the build system where the Boost files are located by defining the WITH_BOOST option。when you invoke CMake. For example:

shell> cmake . -DWITH_BOOST=/usr/local/boost_1_59_0

Adjust the path as necessary to match your installation.

75b1f0e7c6e9fe29336eae5aa84f4661.png

2)在build成功后,C:mysql-5.7.13-buildsqlDebugmysqld.exe 启动MySQL服务可能会报如下错误,然后无论如何更改read_buffer_size还是报这个错误,搜索test_lc_time_sz()这个函数,就可以找到解决方法了,其实是一个DEBUG的断言错误,将sqlmysqld.cc第4283行的DBUG_ASSERT(0);改成DBUG_ASSERT(1);就行了。

key_buffer_size=0

read_buffer_size=131072

max_used_connections=0

max_threads=151

thread_count=0

connection_count=0

It is possible that mysqld could use up to

key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 59879 K b

ytes of memory

Hope that's ok; if not, decrease some variables in the equation.ytes of memory

Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0

Attempting backtrace. You can use the following information to find out

where mysqld died. If you see no messages after this, something went

terribly wrong...

13ff45385 mysqld.exe!my_sigabrt_handler()[my_thr_init.c:449]

14073f4df mysqld.exe!raise()[winsig.c:594]

14073c3f0 mysqld.exe!abort()[abort.c:82]

140724d58 mysqld.exe!_wassert()[assert.c:156]

13f1c5177 mysqld.exe!test_lc_time_sz()[mysqld.cc:4283]

13f1c5511 mysqld.exe!win_main()[mysqld.cc:4536]

13f1c6067 mysqld.exe!mysql_service()[mysqld.cc:5035]

13f1c693f mysqld.exe!mysqld_main()[mysqld.cc:5233]

13f1b803f mysqld.exe!main()[main.cc:26]

14071f19c mysqld.exe!__tmainCRTStartup()[crt0.c:255]

14071f2de mysqld.exe!mainCRTStartup()[crt0.c:165]

76c45a4d kernel32.dll!BaseThreadInitThunk()

76d7b831 ntdll.dll!RtlUserThreadStart()

还可能会在启动mysqld服务的时候遇到这个错误,http://stackoverflow.com/questions/33691038/issue-when-running-mysqld,解决方法是"To do this right click the

Command Prompt startup icon and then select Run As Admininistrator. Then run mysqld and you should no longer see that error."

E:Softwaresmysql-5.7.9-winx64bin>mysqld

mysqld: Could not create or access the registry key needed for the MySQL application

to log to the Windows EventLog. Run the application with sufficient

privileges once to create the key, add the key manually, or turn off

logging for that application.

3)启动mysqld服务时,注意:

mysqld --initialize

这个命令初始化你指定的数据目录下的数据(就是一些预设表),mysql参考手册里也有详细说明mysql到底初始化了些什么,并且在C:mysql-5.7.13-buildsqldata目录下的.err文件中告诉你初始密码。

从这一段可以知道,--initialize-insecure选项不会生成随机的密码,mysql.exe可以使用无密码登录MySQL, mysql -u root --skip-password。而--initialize必须使用密码登录。

Regardless of platform, use --initialize for “secure by default” installation (that is, including

generation of a random initial root password). In this case, the password is marked as expired and

you will need to choose a new one. With the --initialize-insecure option, no root password is

generated; it is assumed that you will assign a password to the account in timely fashion before putting

the server into production use.

然后启动mysql.exe,C:mysql-5.7.13-buildclientDebugmysql.exe 使用命令mysql -u root -p 登录。如果觉得初始密码太复杂,可以改成自己熟悉的密码,ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

4)关于my.ini文件需要注意一点,当时我在更改read_buffer_size这个参数时,就是无法生效。mysql默认查找配置文件的路径:程序首先会分别收集windows系统目录、C:根目录、执行码所在的父目录,如果配置了环境变量MYSQL_HOME,这个目录也会被搜集,然后在这些目录下进行查找my.ini文件。所以C:mysql-5.7.13-buildsqlDebug是mysqld的目录,而my.ini一定要放在他的父目录下,就是C:mysql-5.7.13-buildsql这个目录下,放在C:mysql-5.7.13-build还是C:mysql-5.7.13-buildsqlDebug都是无效的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值