You need the following tools to build MySQL from source on Unix:
A working ANSI C++ compiler. GCC 4.2.1 or later, Sun Studio 10 or later, Visual Studio 2008 or later, and many current vendor-supplied compilers are known to work.
MySQL client libraries and include files from MySQL 4.0.0 or higher (preferably 4.0.16 or higher). This is required because Connector/ODBC uses calls and structures that exist only starting from that version of the library. To get the client libraries and include files, visit http://dev.mysql.com/downloads/.
A compatible ODBC manager must be installed. Connector/ODBC
is known to work with the
unixODBC managers. See
Section 3.2, “ODBC Driver Managers” for more
If you are using a character set that is not compiled into
the MySQL client library, install the MySQL character
definitions from the
SHAREDIR (by default,
These should be in place if you have installed the MySQL
server on the same machine. See Character Set Support
for more information on character set support.
Once you have all the required files, unpack the source files to a separate directory, then run cmake with the following command:
cmake -G "Unix Makefiles"
You might need to help cmake find the MySQL
headers and libraries by setting the environment variables
MYSQL_DIR to the appropriate locations; for
When you run cmake, you might add options to the command line. Here are some examples:
Use when the ODBC include directory is not found within the
Use when the ODBC library directory is not found within the
Enables unixODBC support.
iODBC is the
default ODBC library used by Connector/ODBC. Alternatively,
unixODBC may be used by setting this
option to “1”.
By default, Connector/ODBC is linked statically with the
MySQL client library
If you want to link dynamically or to another MySQL client
library, use this option to supply the client library's
Specifies location of the utility
mysql_config, which is
used to fetch values of the variables
MYSQL_CXXFLAGS. Values fetched by
mysql_config can be
overridden by values provided directly to
cmake as parameters.
Enables C++ linkage to MySQL client library. By default,
MYSQL_CXX_LINKAGE is enabled for MySQL
5.6.4 or later. For MySQL 5.6.3 and earlier, this option
must be set explicitly to
To build the driver libraries, execute make:
If any errors occur, correct them and continue with the build process. If you are not able to finish the build, see Section 9.1, “Connector/ODBC Community Support”.
To install the driver libraries, execute the following command:
For more information on build process, refer to the
BUILD file that comes with the source
Some tests for Connector/ODBC are provided in the distribution with the libraries that you built. To run the tests:
Make sure you have an
in place, by which you can configure your DSN entries. A
odbc.ini file is generated by
the build process under the
folder. Set the environment variable
ODBCINI to the location of your
Set up a test DSN in your
Section 5.5, “Configuring a Connector/ODBC DSN on Unix”
for details ). A sample DSN entry, which you can use for
your tests, can be found in the sample
Set the environment variable
to the name of your test DSN.
Set the environment variable
and perhaps also
TEST_PASSWORD to the
user name and password for the tests, if needed. By
default, the tests use “root” as the user and
do not enter a password; if you want the tests to use
another user name or password, set
Make sure that your MySQL server is running.
Run the following command: