Troubleshoot problems with using dbexpress to connect MySQL database in Delphi XE

Source: Internet
Author: User

Troubleshoot problems with using dbexpress to connect MySQL database in Delphi XE

  

The Delphi IDE contains a component of Data Explorer, as shown in:

The component is based on dbexpress (including Tsqlconnection, Tsqldataset, Tsqlquery, Tsqlstoredproc, tsqltable, Tsqlservermethod, TSQLMonitor, Tsimpledataset). However, because the component provides only abstract drivers for a variety of databases and does not provide the underlying driver libraries that interact directly with the database, it is also necessary to work with a provider driver to use a particular database. In this paper, Delphi XE in Windows 7 Ultimate version of the system to connect the MySQL Community Server 5.5.10 database As an example, I introduced the implementation of the problem encountered in the process, I hope to meet the same problem of friends have helped.

First, the author took one of the biggest detours, in order to save the trouble, in the Windows 7 system using the MSI version of the MySQL database (why is the biggest detour and see below). After installing the service what the toss of a big circle, the key is that the service does not start up. If you are using a graphical MySQL Server Instance Configuration Wizard, be sure to note that when choosing a database for multifunctional or transactional When only, the wizard will let you specify InnoDB tablespace. Your machine if you have previously installed MySQL, this directory can not be used to install the previous instance of the InnoDB tablespace, preferably a new directory, or it is easy to trigger the MySQL service can not start the failure.

Second, in order to do the test, do not add an additional user account in the MySQL server, because the default policy, MySQL to the root account is forbidden remote access, no wonder I try to connect a bit of local problems are not, another on the same LAN on the machine to log on the server on the error. The solution is as follows:

Go to MySQL console. In the cmd location to the MySQL installation directory bin subdirectory, input mysql-u root-p, enter will ask you to enter the root account password, if there is no password directly enter, otherwise input root password, return. If you see mysql> indicates a successful login.

Switch to MySQL status using System database, input: use MySQL;

If you have already set the root password, please ignore this step, otherwise enter UPDATE user set Password=password (' Your root Password ') WHERE user= ' root '; In parentheses, you enter the password of the root account you specified in the quotation marks. At the end of the statement, don't forget to end with a semicolon, enter. This sets the password for the root account.

Input: GRANT all privileges on * * to [email protected]'%' identified by ' root '; This set up the root account can be remote from any computer login, of course, this is only for experimentation, the real application environment is not recommended such use, there will be a great security risk.

Important, don't forget to apply the settings just now. Input: FLUSH privileges; This is the only way to allow the permission settings in the previous step to take effect.

The above two points just to ensure that MySQL can run in Windows 7 system, and can be remote access, if you have done the above two points, please ignore (haha, said late)

The reason for using data Explorer here is that it can be used to test whether the dbexpress can connect to the MySQL database without building a project. Expand the MySQL node and modify the corresponding connections listed, as shown in:

After the parameters are configured, click the "Test Connection" button in the lower left corner to test the connection if you get the hint as shown (Driver could not be properly initialized. Client library May is missing, not installed properly, the of the wrong version, or the driver is missing from the system Path.):

Then follow the following method:

Copy the Libmysql.dll file from the Lib subdirectory in the MySQL installation directory to the C:/windows/system32 (the system is not on the C drive, go to the corresponding directory), restart the Delphi XE, follow the steps above to test the connection, You will see that there is still an issue that does not initialize the database driver correctly. I was plagued by this problem for three days, the final solution is very absurd, remember the first I said the "biggest detour"? The biggest detour is the use of the installation version of MySQL. You just have to use the decompression version of the MySQL database to be no problem. In fact, the real thing here is still libmysql.dll. as long as you extract the version of Libmysql.dll from the extracted version of MySQL to the C:/windows/system32 directory, there will be no problem of properly initializing the database driver.

After the program has been developed, it needs to be deployed. Do not forget to deploy the dbexpress corresponding to the MySQL database of the abstract driver Dbxmys.dll and the mysql underlying driver libmysql.dll are placed in the same directory as the main program.

Attached: The available MySQL database drivers that are mentioned in this article: http://download.csdn.net/source/3114666

Troubleshooting using dbexpress to connect MySQL database in Delphi XE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.