如何远程连接mysql服务器. [英] how to connect mysql server remotly.
本文介绍了如何远程连接mysql服务器.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<configuration>
<appsettings>
<add key="ohpc_connectionstring" value="SERVER=192.168.15.130;User Id=root;pwd=password;database=ohpc_new1;Persist Security Info=True" />
</appsettings>
</configuration>
我已经在app.config文件中声明了此代码,但无法正常工作并显示错误消息.因此,如何修改代码以从我们的远程服务器访问mysql数据库.对于mysql数据库,用户标识= root,但我们尚未为数据库设置任何密码.
[edit]添加了代码块和HTML编码,以使代码片段可见! -OriginalGriff [/edit]
I have declare this code in app.config file but It does not work properly and show error message. So how can I modify the code to access mysql database from our remote server. For mysql database userid =root but we have not set any password for database.
[edit]Code block and HTML encode added to make code fragment visible! - OriginalGriff[/edit]
推荐答案
亲爱的,
在app.config文件中尝试此代码
Hi Dear,
try this code in app.config file
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<connectionStrings>
<add name="SqlServerConnectionstring" connectionString="Password=password;Connection Timeout=0;Persist Security Info=False;User ID=userid;Initial Catalog=Database Name;Data Source=servername;" />
</connectionStrings>
</configuration>
在C#表单页面中,使用以下代码访问SqlServerConnectionstring
in C# form page use the following code to acces the SqlServerConnectionstring
ConfigurationManager.ConnectionStrings["SqlServerConnectionstring"].ToString();
<configuration>
<appSettings>
<add key ="Connstr" value="SERVER=192.168.15.130\SQLExpress;
database=databaseName;uid=UserId;pwd=Password"></add>
</appSettings>
</configuration>
这篇关于如何远程连接mysql服务器.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文