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

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?

Related

How to know where my MySQL database is being hosted and how can I access it?

I have the following information to a SQL database
Server : MyUserName.mysql.db
User : MyUserName
Password : MyPassWord
I am a little noob in this context, so I have some questions:
How to know where is hosted my database? Is it in mysql domain? (Isn't that the type of database?)
How can I access it and visualize it?
To begin with, you need a CLIENT to be able to access your database. For MySQL, you can use either Workbench or MySQL CLIENT (the last giving you command-line level access).
Second, and according to your information, the server is MyUserName.mysql.db so if you try to PING that server you should get some response.
Third, MySQL has a default port number so you need to configure your client to access that server though that port (if I'm not mistaking, 3306).
You will also need access credentials to your database.
Your DB administrator should be able to provide all the information you need.
Contact your database administrator.
If you're trying to acess/visualize sql server database on your local computer install ssms to connect to your local database , similarly you can access any other database through ssms.

Multiple server cluster setup. How do I track which server is connecting to the parent mysql?

I have a setup of 12 download servers, they all have their ip and login details in a mysql database on my database server.
The database has a dlserver_details table with following fields:
id, server name, location, domain, ip address, additional ips
Each row in this table has a specific server's records.
How do I find out which server is connecting to the mysql so that mysql can send the correct server's information?
For example if Server A is connecting to mysql through remote sql, there is no way of knowing which row belongs to Server A.
The solution I came up with 4 years ago was to assign each server an id manually and save it in a file called config.php
When the server wants to fetch its details from the mysql db, it sends query like:
$serverid = 4;
SELECT * from dlserver_details where id = $serverid
Which works perfectly fine.
But the problem is that this solution is not very efficient as we are scaling up. Whenever we add servers to the cluster, we have to modify some files and the database. This slows things down as the files are synced automatically to all the download servers then I have to manually assign the correct server id and update its records in the database.
Is there a proper solution to this? Like Can I track with mysql which host is connecting to it for the query so that it can look for the correct record for that host on its own?
Something like:
lets say mysql ip is 1.1.1.1 and client server ip is 2.2.2.2
row in the table:
id = 4
ip = 2.2.2.2
servername = Server A
Query: SELECT * FROM dlserver_details WHERE ip = CONNECTING_HOST_IP
Would that work?
Ended up doing it with:
... WHERE ip = (Select SUBSTRING_INDEX(host, ':', 1) From information_schema.processlist WHERE ID = connection_id())

Connection to MySQL server fails

I'm trying to access a database from the default Linux MySQL client, but all I get is a timeout. It's actually the database used by a WordPress website, and in the configuration file I can see that the IP address of the DB server is actually localhost (127.0.0.1). So I assume that the host name of the DB server is the same as the website's.
I am able to connect to the database with a PHP script that I wrote and uploaded to the server with this same information, and with the show variables query I was able to verify the port number (which was 3306) and specify it to the client. I can see a lot of variables but I'm not sure which one to use.
Any help?
If your Wordpress site is remote, you must connect to DB server like remote connection not local connection. If wordpress and DB server are in the same server, the configuration file to connect with DB is localhost, but if you want connect from remote host you must config your connecto with remote data.

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';

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.
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.