delphi连接mysql不用添加DSN(mysql connector odbc 5.1版)

一、下载安装mysql驱动
http://mysql.com/downloads/connector/odbc/
二、添加adoconnection,adoquery,使用以下连接字符串
http://www.connectionstrings.com/mysql#p31
adoconnection的属性ConnectionString填入以下所需要的连接情况对应字符串,在软件发布时,把mysql-connector-odbc-5.1.8-win32.msi安装程序一起附带着,先安装驱动,即可正常使用。

Local database
Driver= {MySQL ODBC 5.1 Driver}; Server= localhost; Database= myDataBase; User= myUsername; Password= myPassword; Option= 3;
 
Remote database
Driver= {MySQL ODBC 5.1 Driver}; Server= myServerAddress; Database= myDataBase; User= myUsername; Password= myPassword; Option= 3;
 
Specifying TCP/IP port
Driver= {MySQL ODBC 5.1 Driver}; Server= myServerAddress; Port= 3306; Database= myDataBase; User= myUsername; Password= myPassword; Option= 3;
 
Specifying character set
Driver= {MySQL ODBC 5.1 Driver}; Server= myServerAddress; charset= UTF8; Database= myDataBase; User= myUsername; Password= myPassword; Option= 3;
 
Specifying socket
This one specifies the Unix socket file or Windows named pipe to connect to. Used only for local client connections.
Driver= {MySQL ODBC 5.1 Driver}; Server= myServerAddress; Database= myDataBase; User= myUsername; Password= myPassword; Socket= MySQL; Option= 3;
On Windows, the socket variable is the name of the named pipe that is used for local client connections. The default value is MySQL.

On Unix platforms, the socket variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock.
 
Using SSL
Driver= {MySQL ODBC 5.1 Driver}; Server= myServerAddress; Database= myDataBase; User= myUsername; Password= myPassword; sslca= c:/cacert.pem; sslcert= c:/client-cert.pem; sslkey= c:/client-key.pem; sslverify= 1; Option= 3;
SSLCA specifies the path to a file with a list of trust SSL CAs

SSLCERT specifies the name of the SSL certificate file to use for establishing a secure connection.

SSLKEY specifies the name of the SSL key file to use for establishing a secure connection.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值