Describes how to connect to MySQL Server.
The AnyDAC native driver supports the MySQL Server Community, Enterprise and Embedded editions version 3.21 and higher.
AnyDAC requires one of the following x86 or x64 libraries:
You can take them from a server (
details) installation Bin folder and put into a folder:
[MySQL] VendorLib=<folder>\libmysql.dll
When the MySQL client library has not been properly installed, you will get an exception when you try to connect:
[AnyDAC][Phys][MySQL]-314. Cannot load vendor library [libmysql.dll]. The specified module could not be found. Check [libmysql.dll], which is located in one of the PATH directories or in application EXE directory.
AnyDAC requires:
To install on Linux use the commands:
sudo apt-get update sudo apt-get install libmysqlclient16 sudo ln -s /usr/lib/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so
AnyDAC requires:
You can download it as Connector/C for Mac OS X (
here). And extract it into /usr/local folder, using the command:
sudo tar -C /usr/local -zxvf mysql-connector-c-6.0.2-osx10.5-x86-32bit.tar
To link the driver:
To connect to a MySQL DBMS, most applications will need to specify DriverID, Server, Database, User_Name, Password, CharacterSet.
DriverID=MySQL
|
Parameter |
Description |
Example value |
|
Server |
The TCP/IP address or host name of the server running a MySQL server. |
127.0.0.1 |
|
Port |
The TCP/IP port on which the MySQL server is listening. |
3306 |
|
Database |
Name of the current database for the connection. If the Database is not specified, no current database is set up. |
MyDB |
|
User_Name |
The MySQL user ID. |
root |
|
Password |
The MySQL user password. |
|
|
CharacterSet |
The default character set for the connection. The connection collation becomes the default collation of the character set. See the SET NAMES statement for details. |
cp1251 |
|
Compress |
Specify True to enable network traffic compression. By default, it is set to False. |
|
|
UseSSL |
Specify True to enable SSL connection. By default, it is set to False. Setting UseSSL=True requires additionally specify connection definition parameters:
MySQL documentation. |
True |
|
LoginTimeout |
Controls the amount of time (in seconds) an application waits for a connection attempt to timeout while waiting to establish a connection. |
30 |
|
ReadTimeout |
The timeout in seconds for attempts to read from the server. Each attempt uses this timeout value and there are retries if necessary, so the total effective timeout value is three times the option value. You can set the value so that a lost connection can be detected earlier than the TCP/IP Close_Wait_Timeout value of 10 minutes. This option works only for TCP/IP connections and, prior to MySQL 5.1.12, only for Windows. By default, it is not set. |
5 |
|
WriteTimeout |
The timeout in seconds for attempts to write to the server. Each attempt uses this timeout value and there are net_retry_count retries if necessary, so the total effective timeout value is net_retry_count times the option value. This option works only for TCP/IP connections and, prior to MySQL 5.1.12, only for Windows. By default, it is not set. |
5 |
|
ResultMode |
Controls how to fetch a result set to a client. The default value is Store.
|
Use |
|
TinyIntFormat |
Controls the TINYINT(1) representation. The default value is Boolean.
|
Integer |
|
MetaDefCatalog |
Default database name. Design time code will exclude the catalog name from the object name if it is equal to MetaDefCatalog. Setting the MetaDefCatalog does not change the current database in the MySQL session. |
MyDB |
Major notes:
To prepare your application to work with a MySQL Embedded server, you should take the following actions:
To connect to MySQL Embedded server you should not specify Server, Host, Port, User_Name, Password connection definition parameters. If you does not specify --skip-networking argument, then using libmysqld.dll you can connect to the remote MySQL servers, the same as with normal libmysql.dll.
Simple setup example:
App folder: <app>.EXE LIBMYSQLD.DLL errmsg.sys <DB files> Arguments: --language=./ --skip-innodb --skip-networking
Extended setup example:
App folder: <app>.EXE LIBMYSQLD.DLL share\* share\charsets data\* data\<DB files> Arguments: --datadir=./data --skip-innodb --skip-networking
DriverID=MySQL Database=addemo User_Name=root Password=
DriverID=MySQL Server=mysrv Port=3307 Database=addemo CharacterSet=utf8 User_Name=me Password=123
DriverID=MySQL Database=addemo CharacterSet=utf8
DriverID=MySQL Server=mysrv Port=3307 Database=addemo UseSSL=True SSL_ca=ca-cert.pem SSL_cert=client-cert.pem SSL_key=client-key.pem
|
What do you think about this topic? Send feedback!
|