简体   繁体   English

如何使用主机名和凭据连接到MySQL数据库并获取表?

[英]How to Connect to A MySQL DB and Get Tables Using Hostname and Credentials?

I am really sorry if this is not the right place to post this question. 如果这不是发布此问题的正确位置,我真的很抱歉。 If it is not, please mark the thread and close it. 如果不是,请标记线程并关闭它。 A client sent me some files which needs to be edited and some functionalities added. 客户端向我发送了一些需要编辑的文件,并添加了一些功能。 But he didn't send me MySQL tables which is necessary in order to install it on my server. 但他没有发给我MySQL表,这是为了在我的服务器上安装它所必需的。 I have database credentials (like hostname, password and username). 我有数据库凭据(如主机名,密码和用户名)。 The host-name is something like: abcd1234.secureserver.net. 主机名如下:abcd1234.secureserver.net。 Is it possible to get table structure using these information? 是否可以使用这些信息获取表结构?

Thanks and regards, Abhisek 谢谢和问候,Abhisek

Use mysqldump with -H parameter to specify the hostname. 使用带有-H参数的mysqldump指定主机名。 Also use -d if you want only the structure of the tables and not the data. 如果只需要表的结构而不是数据,也可以使用-d

The above assumes that the MySQL server is listening on the public IP. 以上假设MySQL服务器正在侦听公共IP。 If not, then you have to login to the server and run mysqldump locally without -H . 如果没有,那么你必须登录服务器并在没有-H情况下在本地运行mysqldump

Agree to @nikhil500. 同意@ nikhil500。

But in some cases, the remote access of MySQL is closed for security reason. 但在某些情况下,出于安全原因,MySQL的远程访问将被关闭。 So just try telnet abcd1234.secureserver.net 3306 (change 3306 to default port if needed) see if you can success connect to this mysql without connection deny. 所以只需尝试telnet abcd1234.secureserver.net 3306(如果需要,将3306更改为默认端口)看看你是否能成功连接到这个没有连接拒绝的mysql。

If you can connect it, then use 如果您可以连接它,那么使用

mysqldump -H abcd1234.secureserver.net --default-character-set=utf8 --opt -u$DB_USER -p$DB_PASS $DB_NAME > $YOUR_FILE mysqldump -H abcd1234.secureserver.net --default-character-set = utf8 --opt -u $ DB_USER -p $ DB_PASS $ DB_NAME> $ YOUR_FILE

Other case, you should ask your client to execute mysqldump in his server or request an remote access setting in the server. 在其他情况下,您应该要求您的客户端在其服务器中执行mysqldump或请求服务器中的远程访问设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM