简体   繁体   English

如何在MySqL中将表db复制到db

[英]How can I copy table db to db in MySqL

$server_net=mysql_connect("xxx.xxx.170.54","net_db","dbpass") or die("SQL server error..!");
@mysql_select_db("net_db",$server_net) or die("database error..");
#------------------------------------------------------------------
$server_local=mysql_connect("localhost","","") or die("SQL server error.!");
@mysql_select_db("local_db") or die("Database error..");



mysql_query("DROP TABLE IF EXISTS net_db.komisyon",$server_net);
mysql_query("CREATE TABLE net_db.komisyon SELECT * FROM local_db.komisyon");

How can I copy table from local to net ?? 如何将表从本地复制到网络? I want to create table on server like local table. 我想在服务器上创建像本地表一样的表。 When I run this query give error (Unknown database) 当我运行此查询时给出错误(未知数据库)

You're sending the CREATE TABLE command to your network server, but it doesn't have any connection to the local_db database. 您正在将CREATE TABLE命令发送到网络服务器,但它与local_db数据库没有任何连接。

You must either export the data from your local database in some manner (probably best to use mysqldump , although you could also load it into PHP and then INSERT into your network database), or else look into MySQL replication or clustering to keep the databases synchronised. 您必须以某种方式从本地数据库导出数据(可能最好使用mysqldump ,尽管您也可以将其加载到PHP然后INSERT到您的网络数据库中),或者查看MySQL 复制群集以保持数据库同步。

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

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