How can I copy table db to db in MySqL - 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.
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.

Related

Error "Error parsing DDL" when trying to ALTER TABLE with ENCRYPTION = 'Y' (keyring plugin) in MySQL 5.7.22

I configured my MySQL 5.7.22 instance with
early-plugin-load = keyring_file.dll
in my.ini, restarted the service (on Windows Server 2016 Standard)
then I created a table:
CREATE TABLE t1 (c1 INT) ENCRYPTION='Y';
Table was created correctly and it looks like the data is really encrypted (by looking into MySQL data folder).
But when I try to ALTER the table (in Workbench) I see this:
Why do I get this "Error parsing DDL"?
Other statements like INSERT or SELECT works okay on this encrypted table.
Also ALTER on a non-encrypted table works normally.
I updated MySQL workbench and it works fine now :-)

Transfer data from Local (XAMPP) Database to Remote (Live) Database

I have some data (25k rows) in my Local database table and now I want to go live by copying the data to remote database.
Found some solutions, but not clear how to use the remote server password etc.
Local DB does not have a password, but the remote DB does.
INSERT INTO to_database.to_table SELECT * FROM from_database WHERE some_id = 123;
Typically if I run the above query in local SQL it should happen, but how to specify the remote DB details like host, DBname, Userid, Password etc?

SQL Linked Server to MySQL database does not work because of missing or´incorrect schema

I want to establish a linked Server Connection from my Office SQL-Server to a web hosted MySQL-database.
Before that I tried to Setup a Connection to a copy of this MySQL-database on localhost.
I created a linked Server in Management Studio pointing to my MySQL-database
it Looks like this:
Testing the Connection was OK, I can see all databases in MySQL.
But when I do a SELECT on one of the tables in a certain database I get an error 7312.
When I generate a select script by SSMS it Comes up with
Select * from [MYSQL_local_ASV].[asvdb]..[descriptions]
not showing any Schema (..) althoug I can connect to the Server.
If I check the table's Schema in MySQL Workbench it Shows the Schema name 'asvdb'. For me it Looks like there is a Schema 'asvdb' with a database called 'asvdb'.
I checked also with [MYSQL_local_ASV].[asvdb].[asvdb].[descriptions].
Same error.
Maybe someone can explain me whats wrong with this and have some example of how to connect to a table in a linked Server.
So, the Problem is, I assumed that database and Schema in mysql are the same, but what does SQL-Server Need to complete the Connection string properly?
If I cannot establish this local connectin I will never get it to a web hosted MySQL-database, so please help me!
Thanks
Michael
use this format for select query
Execute ('select * from tablename')at LinkedServername

Error in configuring MySql workbench - Failed to connect to MySql at localhost

I am new to MySql workbench and never needed to use a lot of DBs before now.
I had an sql script containing all the DB creation, tables, population etc.
So using MySql workbench, I Reversed Engineering Using a Create Script.
Fine, it worked as I can see my tables.
Now I want perform some select over my data and I first need to create a new connection,
So I tried to Creating a MySQL Connection
but when I test the connection, I get the following error: "Failed to connect to MySql server on 127.0.0.1" (10061).
Question: what to use in the below menu (Connection/RemoteManagement/System Profile) or what else could be my problem?
my problem was that I didnt have a db, so I decided to use wampserver which includes everything and it's very simple to use.

How to setup/map remote mysql db in local phpmyadmin

I am working on a remote development server. I have the mysql host name, db name, user name , password of that remote server. I want to setup/replicate/map that dev server mysql in my local phpmyadmin, so that I can access the remote server db locally(for ex :- /mylocalip/remote-server-db).
Thus I don't have to do ssh connection and open the mysql in terminal. How can we do this in phpmyadmin/config.inc.php.
Let me explain again through an example. Lets say the remote server db is accessible through 213.81.203.130/phpmyadmin. I want to access that db from my local ip through an alias name by creating a mapping i.e 192.168.10.140/remote-db. Basically this can be done by adding some sort of code in phpmyadmin/config.inc.php or config.db.php. But how to do it I am not sure.
If you want to avoid using terminal, why not try MySQL Workbench to connect to the database?
UPDATE
In light of all the views to this question, I am adding a solution that more accurately matches the question. Please see this link, I believe it will be helpful. It involves editing the phpmyadmin config.inc.php file to add additional servers. This is how you can keep your localhost connection, and add any remote db connections. Simply select the server from the drop down at the login screen to phpmyadmin.
There are 3 methods to set this up
METHOD #1 : MySQL Replication
Setup MySQL Replication where the Slave has this option
replicate_do_table=mydb.mytable
Then, any DML (INSERT, UPDATE, DELETE) or DDL (ALTER TABLE) you execute will go immediately to serverB. This makes Method #1 is the fastest and most granular approach.
METHOD #2 : Copying the table to the other server
Rather than rehash, Here is an earlier post, Mr. RolandoMySQLDBA did May 31, 2011 for this method : [How do you copy a table from MySqlServer_A to MySqlServer_B?][1]
METHOD #3 : FEDERATED Table (MyISAM Only)
Suppose mytable on serverA looks like this
CREATE TABLE mydb.mytable ( ... ) ENGINE=MyISAM;
You can a mapping of the target table in serverB by running this on serverA like this
CREATE TABLE mydb.mytable_remote LIKE mytable; ALTER TABLE
mydb.mytable_remote ENGINE=FEDERATED
CONNECTION='mysql://username:password#serverB/mydb/mytable';