You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

289 lines
13 KiB

  1. 2.5.10. Installing MySQL from Source on Windows
  2. These instructions describe how to build binaries from source for
  3. MySQL 5.1 on Windows. Instructions are provided for building
  4. binaries from a standard source distribution or from the Bazaar
  5. tree that contains the latest development source.
  6. Note
  7. The instructions here are strictly for users who want to test
  8. MySQL on Microsoft Windows from the latest source distribution or
  9. from the Bazaar tree. For production use, we do not advise using a
  10. MySQL server built by yourself from source. Normally, it is best
  11. to use precompiled binary distributions of MySQL that are built
  12. specifically for optimal performance on Windows by Oracle
  13. Corporation. Instructions for installing binary distributions are
  14. available in Section 2.5, "Installing MySQL on Windows."
  15. To build MySQL on Windows from source, you must satisfy the
  16. following system, compiler, and resource requirements:
  17. * Windows 2000, Windows XP, or newer version.
  18. Windows Vista is supported when using Visual Studio 2005
  19. provided you have installed the following updates:
  20. + Microsoft Visual Studio 2005 Professional Edition - ENU
  21. Service Pack 1 (KB926601)
  22. (http://support.microsoft.com/?kbid=926601)
  23. + Security Update for Microsoft Visual Studio 2005
  24. Professional Edition - ENU (KB937061)
  25. (http://support.microsoft.com/?kbid=937061)
  26. + Update for Microsoft Visual Studio 2005 Professional
  27. Edition - ENU (KB932232)
  28. (http://support.microsoft.com/?kbid=932232)
  29. * CMake, which can be downloaded from http://www.cmake.org.
  30. After installing, modify your path to include the cmake
  31. binary.
  32. * Microsoft Visual C++ 2005 Express Edition, Visual Studio .Net
  33. 2003 (7.1), or Visual Studio 2005 (8.0) compiler system.
  34. * If you are using Visual C++ 2005 Express Edition, you must
  35. also install an appropriate Platform SDK. More information and
  36. links to downloads for various Windows platforms is available
  37. from
  38. http://www.microsoft.com/downloads/details.aspx?familyid=0baf2
  39. b35-c656-4969-ace8-e4c0c0716adb.
  40. * If you are compiling from a Bazaar tree or making changes to
  41. the parser, you need bison for Windows, which can be
  42. downloaded from
  43. http://gnuwin32.sourceforge.net/packages/bison.htm. Download
  44. the package labeled "Complete package, excluding sources".
  45. After installing the package, modify your path to include the
  46. bison binary and ensure that this binary is accessible from
  47. Visual Studio.
  48. * Cygwin might be necessary if you want to run the test script
  49. or package the compiled binaries and support files into a Zip
  50. archive. (Cygwin is needed only to test or package the
  51. distribution, not to build it.) Cygwin is available from
  52. http://cygwin.com.
  53. * 3GB to 5GB of disk space.
  54. The exact system requirements for Visual Studio can be found here:
  55. http://msdn.microsoft.com/vstudio/Previous/2003/sysreqs/default.as
  56. px and
  57. http://msdn.microsoft.com/vstudio/products/sysreqs/default.aspx
  58. You also need a MySQL source distribution for Windows, which can
  59. be obtained two ways:
  60. * Obtain a source distribution packaged by Oracle Corporation.
  61. These are available from http://dev.mysql.com/downloads/.
  62. * Package a source distribution yourself from the latest Bazaar
  63. developer source tree. For instructions on pulling the latest
  64. source files, see Section 2.3.3, "Installing from the
  65. Development Source Tree."
  66. If you find something not working as expected, or you have
  67. suggestions about ways to improve the current build process on
  68. Windows, please send a message to the win32 mailing list. See
  69. Section 1.6.1, "MySQL Mailing Lists."
  70. 2.5.10.1. Building MySQL from Source Using CMake and Visual Studio
  71. You can build MySQL on Windows by using a combination of cmake and
  72. Microsoft Visual Studio .NET 2003 (7.1), Microsoft Visual Studio
  73. 2005 (8.0), Microsoft Visual Studio 2008 (9.0) or Microsoft Visual
  74. C++ 2005 Express Edition. You must have the appropriate Microsoft
  75. Platform SDK installed.
  76. Note
  77. To compile from the source code on Windows you must use the
  78. standard source distribution (for example, mysql-5.1.46.tar.gz).
  79. You build from the same distribution as used to build MySQL on
  80. Unix, Linux and other platforms. Do not use the Windows Source
  81. distributions as they do not contain the necessary configuration
  82. script and other files.
  83. Follow this procedure to build MySQL:
  84. 1. If you are installing from a packaged source distribution,
  85. create a work directory (for example, C:\workdir), and unpack
  86. the source distribution there using WinZip or another Windows
  87. tool that can read .zip files. This directory is the work
  88. directory in the following instructions.
  89. Note
  90. You must run the commands in the win directory from the
  91. top-level source directory. Do not change into the win
  92. directory, as the commands will not be executed correctly.
  93. 2. Start a command shell. If you have not configured the PATH and
  94. other environment variables for all command shells, you may be
  95. able to start a command shell from the Start Menu within the
  96. Windows Visual Studio menu that contains the necessary
  97. environment changes.
  98. 3. Within the command shell, navigate to the work directory and
  99. run the following command:
  100. C:\workdir>win\configure.js options
  101. If you have associated the .js file extension with an
  102. application such as a text editor, then you may need to use
  103. the following command to force configure.js to be executed as
  104. a script:
  105. C:\workdir>cscript win\configure.js options
  106. These options are available for configure.js:
  107. + WITH_INNOBASE_STORAGE_ENGINE: Enable the InnoDB storage
  108. engine.
  109. + WITH_PARTITION_STORAGE_ENGINE: Enable user-defined
  110. partitioning.
  111. + WITH_ARCHIVE_STORAGE_ENGINE: Enable the ARCHIVE storage
  112. engine.
  113. + WITH_BLACKHOLE_STORAGE_ENGINE: Enable the BLACKHOLE
  114. storage engine.
  115. + WITH_EXAMPLE_STORAGE_ENGINE: Enable the EXAMPLE storage
  116. engine.
  117. + WITH_FEDERATED_STORAGE_ENGINE: Enable the FEDERATED
  118. storage engine.
  119. + WITH_NDBCLUSTER_STORAGE_ENGINE (experimental): Enable the
  120. NDBCLUSTER storage engine in the MySQL server; cause
  121. binaries for the MySQL Cluster management and data node,
  122. management client, and other programs to be built.
  123. This option is supported only in MySQL Cluster NDB 7.0
  124. (NDBCLUSTER storage engine versions 6.4.0 and later)
  125. using the MySQL Cluster sources. It cannot be used to
  126. enable clustering support in other MySQL source trees or
  127. distributions.
  128. + MYSQL_SERVER_SUFFIX=suffix: Server suffix, default none.
  129. + COMPILATION_COMMENT=comment: Server comment, default
  130. "Source distribution".
  131. + MYSQL_TCP_PORT=port: Server port, default 3306.
  132. + DISABLE_GRANT_OPTIONS: Disables the --bootstrap,
  133. --skip-grant-tables, and --init-file options for mysqld.
  134. This option is available as of MySQL 5.1.15.
  135. For example (type the command on one line):
  136. C:\workdir>win\configure.js WITH_INNOBASE_STORAGE_ENGINE
  137. WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro
  138. 4. From the work directory, execute the win\build-vs9.bat
  139. (Windows Visual Studio 2008), win\build-vs8.bat (Windows
  140. Visual Studio 2005), or win\build-vs71.bat (Windows Visual
  141. Stidion 2003) script, depending on the version of Visual
  142. Studio you have installed. The script invokes CMake, which
  143. generates the mysql.sln solution file.
  144. You can also use the corresponding 64-bit file (for example
  145. win\build-vs8_x64.bat or win\build-vs9_x64.bat) to build the
  146. 64-bit version of MySQL. However, you cannot build the 64-bit
  147. version with Visual Studio Express Edition. You must use
  148. Visual Studio 2005 (8.0) or higher.
  149. 5. From the work directory, open the generated mysql.sln file
  150. with Visual Studio and select the proper configuration using
  151. the Configuration menu. The menu provides Debug, Release,
  152. RelwithDebInfo, MinRelInfo options. Then select Solution >
  153. Build to build the solution.
  154. Remember the configuration that you use in this step. It is
  155. important later when you run the test script because that
  156. script needs to know which configuration you used.
  157. 6. Test the server. The server built using the preceding
  158. instructions expects that the MySQL base directory and data
  159. directory are C:\mysql and C:\mysql\data by default. If you
  160. want to test your server using the source tree root directory
  161. and its data directory as the base directory and data
  162. directory, you need to tell the server their path names. You
  163. can either do this on the command line with the --basedir and
  164. --datadir options, or by placing appropriate options in an
  165. option file. (See Section 4.2.3.3, "Using Option Files.") If
  166. you have an existing data directory elsewhere that you want to
  167. use, you can specify its path name instead.
  168. When the server is running in standalone fashion or as a
  169. service based on your configuration, try to connect to it from
  170. the mysql interactive command-line utility.
  171. You can also run the standard test script, mysql-test-run.pl.
  172. This script is written in Perl, so you'll need either Cygwin
  173. or ActiveState Perl to run it. You may also need to install
  174. the modules required by the script. To run the test script,
  175. change location into the mysql-test directory under the work
  176. directory, set the MTR_VS_CONFIG environment variable to the
  177. configuration you selected earlier (or use the --vs-config
  178. option), and invoke mysql-test-run.pl. For example (using
  179. Cygwin and the bash shell):
  180. shell> cd mysql-test
  181. shell> export MTR_VS_CONFIG=debug
  182. shell> ./mysql-test-run.pl --force --timer
  183. shell> ./mysql-test-run.pl --force --timer --ps-protocol
  184. When you are satisfied that the programs you have built are
  185. working correctly, stop the server. Now you can install the
  186. distribution. One way to do this is to use the make_win_bin_dist
  187. script in the scripts directory of the MySQL source distribution
  188. (see Section 4.4.2, "make_win_bin_dist --- Package MySQL
  189. Distribution as ZIP Archive"). This is a shell script, so you must
  190. have Cygwin installed if you want to use it. It creates a Zip
  191. archive of the built executables and support files that you can
  192. unpack in the location at which you want to install MySQL.
  193. It is also possible to install MySQL by copying directories and
  194. files directly:
  195. 1. Create the directories where you want to install MySQL. For
  196. example, to install into C:\mysql, use these commands:
  197. C:\> mkdir C:\mysql
  198. C:\> mkdir C:\mysql\bin
  199. C:\> mkdir C:\mysql\data
  200. C:\> mkdir C:\mysql\share
  201. C:\> mkdir C:\mysql\scripts
  202. If you want to compile other clients and link them to MySQL,
  203. you should also create several additional directories:
  204. C:\> mkdir C:\mysql\include
  205. C:\> mkdir C:\mysql\lib
  206. C:\> mkdir C:\mysql\lib\debug
  207. C:\> mkdir C:\mysql\lib\opt
  208. If you want to benchmark MySQL, create this directory:
  209. C:\> mkdir C:\mysql\sql-bench
  210. Benchmarking requires Perl support. See Section 2.15, "Perl
  211. Installation Notes."
  212. 2. From the work directory, copy into the C:\mysql directory the
  213. following files and directories:
  214. C:\> cd \workdir
  215. C:\workdir> mkdir C:\mysql
  216. C:\workdir> mkdir C:\mysql\bin
  217. C:\workdir> copy client\Release\*.exe C:\mysql\bin
  218. C:\workdir> copy sql\Release\mysqld.exe C:\mysql\bin\mysqld.exe
  219. C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E
  220. C:\workdir> xcopy share\*.* C:\mysql\share /E
  221. If you want to compile other clients and link them to MySQL,
  222. you should also copy several libraries and header files:
  223. C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\debug
  224. C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\debug
  225. C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\debug
  226. C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\opt
  227. C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\opt
  228. C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\opt
  229. C:\workdir> copy include\*.h C:\mysql\include
  230. C:\workdir> copy libmysql\libmysql.def C:\mysql\include
  231. Note
  232. If you have compiled a Debug, rather than Release solution,
  233. you can replace Release with Debug in the source file names
  234. shown above.
  235. If you want to benchmark MySQL, you should also do this:
  236. C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E
  237. After installation, set up and start the server in the same way as
  238. for binary Windows distributions. This includes creating the
  239. system tables by running mysql_install_db. For more information,
  240. see Section 2.5, "Installing MySQL on Windows."