使用网站上的MySQL数据库 [英] Using a MySQL Database Located on a Website

查看:115
本文介绍了使用网站上的MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个利用MySQL数据库和PhpMyAdmin的网站.我已经创建了一个数据库(My_db),并以管理员(db_admin)的身份分配了用户名和密码.此用户名与我的控制台用户名(CPanel_user)不同.我还创建了一个表,并向其中插入了一些数据(tbl_test).

我要做的是使用此数据库开发客户端程序.问题是我不知道到该远程数据库的正确连接字符串.我下载了适用于Windows的MySQL连接器,并安装了该连接器,以便将数据库添加到ODBC数据源中,但未成功,因为我不知道在必填字段中应使用哪些参数.

我也使用了try and error方法,但没有帮助.

谁能帮助我,回答我如何将远程MySQL数据库添加到ODBC数据源并通过远程客户端访问它?

Hi Everybody,

I have a website which take advantage of MySQL database and PhpMyAdmin. I''ve created a database (My_db) and assigned a username and password to it as an admin (db_admin). This username is differed from my control panel username (CPanel_user). I also created a table and inserted some data to it (tbl_test).

What I want to do is develop a client program using this database. The problem is that I don''t know the proper connection string to this remote database. I downloaded MySQL connector for windows and installed it in order to add my database to ODBC data sources but it wasn''t successful because I don''t know what parameters I should use in the needed fields.

I used try and error method too but it didn''t help.

Can anyone help me and answer how can i add a remote MySQL database to ODBC data sources and gain access to it via a remote client?

推荐答案

MySQL在例如C#是高级编码.将MS SQL数据库连接到系统更容易.但是有了这段代码,它应该可以工作了.祝你好运!

MySQL connecting in e.g. C# is advance coding. It''s easier to connect an MS SQL database to your system. But with this piece of code it should work. Good luck!!

using namespace sql;

Driver *driver;
Connection *con;

try {
    driver = get_driver_instance();
    con = driver -> connect("tcp://127.0.0.1:3306/test", "root", "admin");
} catch (..) {
    ..
}


此处可能不是连接字符串问题.可能未将远程服务器设置为接受外部连接.如果是这样,外部客户端将无法查看或连接到数据库.

您可以通过Web服务间接公开数据库,甚至可以像JSON服务一样简单.您的客户通过此服务与数据库进行对话.
It may not be a connection string issue here. The remote server may not be setup for accepting outside connections. If so an outside client will not be able to see or connect to the database.

You could expose the database indirectly through a web-service, even something as simple as a JSON service. And your clients talk to the database through this service.


首先,您需要确保数据库服务器接受远程连接,然后安装了MySQL连接器,然后您可以使用服务器名称(远程服务器的IP地址和mysql安装的端口),用户名,密码和数据库名称建立一个新的MySqlConnection.

您可以阅读有关如何在mysql
first of all, u need to make sure the database server accept remote connection, and then you have the MySQL connector installed, and then you can just make a new MySqlConnection with the server name (ip address of the remote server and the port the mysql is installed), username, password, and database name.

you can read more on how to enable remote connection on mysqlhere[^]


这篇关于使用网站上的MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆