[英]Cannot connect Delphi App to mySQL database
I have installed a local server Xampp, which is running mySQL database in Windows. 我已经安装了本地服务器Xampp,该服务器在Windows中运行mySQL数据库。 I created a Database on it with one table.
我在一个表上创建了一个数据库。 The thing is I cannot get a connection to the database when I use the dbExpress TSQLConnection component.
问题是当我使用dbExpress TSQLConnection组件时无法连接到数据库。 When I set the properties as follows:
当我如下设置属性时:
ConnectionName = MYSQLConnection
Driver = MySQL
Database = databaseName
HostName = localhost
password =
UserName = root
When I change the connected property to true, I get the following error: 当我将connected属性更改为true时,出现以下错误:
Borland.Data.TDBXError: DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, of the wrong version, or the driver may be missing from the system path
I have tried making a connection to the database using the Data Explorer, but I still get the above error. 我尝试使用数据资源管理器建立与数据库的连接,但是仍然出现上述错误。 I do not know what I'm missing or doing wrong.
我不知道自己缺少什么或做错了什么。
Im using Delphi-XE2. 我正在使用Delphi-XE2。 with mySQL on the server: MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $.
在服务器上使用mySQL:MySQL客户端版本:mysqlnd 5.0.7-dev-091210-$修订版:304625 $。
I have also tried using an ADO connection, but I do not know how to set the connection string. 我也尝试过使用ADO连接,但是我不知道如何设置连接字符串。
I'm still a noob and just want to learn how to make a connection to a mySQL database running on a web server. 我仍然是菜鸟,只想学习如何建立与网络服务器上运行的mySQL数据库的连接。 I cannot afford to buy any components.
我买不起任何组件。
Try this! 尝试这个!
Did some google Fu - and stumpled upon this link : http://wiltonsoftware.com/posts/view/getting-embarcadero-dbexpress-mysql-working-dbx-error-driver-not-initialized 做了一些谷歌富-并且绊倒了这个链接: http ://wiltonsoftware.com/posts/view/getting-embarcadero-dbexpress-mysql-working-dbx-error-driver-not-initialized
That seems to fit your needs. 这似乎符合您的需求。 My previous answer was no help .. hope the new one is better.
我以前的回答没有帮助..希望新的更好。
Old answer: 旧答案:
Make sure you have Data.DBXMySQL in your uses clause. 确保您的uses子句中有Data.DBXMySQL。
OK. 好。 I'll try a different approach.
我将尝试另一种方法。
Is it working if you setup the connection in the DataExplorer? 如果您在DataExplorer中设置连接是否正常? If not - then it's not a problem with the uses clause.
如果不是的话,那么uses子句就不成问题了。 (and you obviously have tried that - sry . must be tired :-))
(而且您显然已经尝试过-抱歉。一定很累:-))
Otherwise a unit could be like this. 否则,一个单位可能会像这样。
unit Unit1;
interface
uses // <-- Uses normally goes right after interface .... (you probably already have one)
Data.DBXMySql;
implementation
end.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.