mysql workbench connect with multiple database - mysql

I have two different instances on my workbench localhost and remote server instance shopify_data, (default schema sales_report). Now I want to fetch the data from table zipcode in localhost and other fields that are in another table shopify_orders in remote server shopify_data within sales_report.
The query looks like :
SELECT Name, billing_zip, Billing_Name, Billing_Address1,Billing_Address2, Lineitem_name, Created_at
FROM sales_report.shopify_orders
WHERE Created_at between '2017-08-31' and '2017-09-21' and Billing_Zip in (select zip_code from zipcode);
It gives error:
sales_report.shopify_orders does not exists.
How can I connect my local host instance with shopify_data instance and get data within the same query.
Thanks.
Deepak
PS: I don't want to import the shopify_orders into local host as the value keeps dynamically changing with each order and I don't want to repeat importing

It's not possible to access data stored on different servers in a single connection, with MySQL. You always open a connection to a single server and can work with DB objects available on that (provided you have the privileges for that).
I should add there's the option of federated tables. More precisly it's a storage engine, which allows to host data on a remote server in a local table, which then makes it possible to do joins with both local and remote data. But that requires to define such tables first and you cannot use FKs (and there are other limitations).

In workbench you can work with multiple databases on same server in crossing manner mean to say in query window of one database you can access other database tables also.
For this follow the following steps:
The database on which you are working on localhost create this as testdb on your remote server.
Create a mysql user "anydbuser" which can access all database of your server. In plesk this option come when user created from database selection dropdown choose ANY.
now connect testdb using anydbuser.
In query window you can try this query : select * from original_db_name.tablename;
you are able to access result of above db table into testdb query window

Related

Connecting to MySQL database on AWS server from PHPMyAdmin

I am trying to connect to a MySQL database that resides on an AWS server from within PHPMyAdmin, to be able to view its tables.
I have the connection strings (hostname, username, password), but I do not see where I would link or provide the AWS database parameters.
Ultimately what I would like to do with the tables is to use the data in my front-end userform that is created in MS Excel.
Here's what I am able to do successfully:
1. can create MySQL database (testdb)
2. can create a table (testtable) from PHPMyAdmin
3. Use the MySQL for Excel connection service to be able to connect to the testtable in the testdb and use the data in my Excel application.
The problem I am having is bringing or linking to the MySQL database on the AWS server to my testdb. I just want to be able to see a list of the AWS database tables in Phpmyadmin. Is that possible?
Yes, it is possible. You can edit config.inc.php file of phpmyadmin to add as many servers as you want
Here is the link with the guide
https://tecadmin.net/add-multiple-hosts-in-phpmyadmin/

MySQL Workbench - Define database in connection settings

I was wondering whether there is a way to define a specific database in the connection setup of MySQL Workbench (I know this works with other database software). Sometimes I have a lot of different databases on one server and I only want to access one with one connection. Can I specify the database in the connection settings somehow?
YES, On the home tab Click the + in MySQL Connections. And put the database name in the Default Schema: when you fill in all the usual info about ip address etc
Now if you only want to see the one database, then create a new MySQL user account and only allow this new account access to this single database. Then change the connection to the database to use the newly created MySQL account.
I guess you are seeing all the databases because you are using the root account.

View Database Tables From AWS in MySQL Workbench

I have successfully migrated my mysql database file to an aws mysql instance using MySQL Workbench.
I now want to test that everything is migrated properly. When I connect to the db using MySQL Workbench and run an sql query such as
SELECT * FROM Users
I get an error saying that no database has been selected. I'm thinking that I'm actually only connected to the server and not the actual database. Is there a method to connect to the actual db and view all the tables on the server using MySQL Workbench or possibly another tool.
You never connect to a database. A database (aka schema) is just an organizational construct within a database server (aka RDBMS). So, first you connect to that server, to establish the communication. Then you select a schema to work with. Either run a USE command or, in MySQL Workbench, double click on a schema node in the schema tree on the left hand side to make this the current default. You can also set an initial default schema in the connection settings. The current (default) schema is shown in bold in the tree:
Figured it out.
There is a small expand button in the navigator panel on the left which can be expanded and I can view all my tables, columns etc...

Update MySQL Database from values in MS SQL

Basically I have an MS SQL database in one location (location A) and I need to update the results of a specific SQL query in to a MySQL server in another location (location B) which is behind a VPN. The MySql server can only be accessed when connected to the VPN.
I've tried to connect to the VPN on the machine which has the MS SQL database on it (in location A), downloaded the MySql connection software to enable it to connect to a MySql database in an attempt to create a linked server, but alas, that machine when connected to the VPN cannot see the MySql database or at least fails to connect. (I know I'm using the correct security credentials).
I should probably mention that this MS SQL machine is a file server with a fixed IP address and hence fixed DNS etc. I think this may have something to do with why it's failing.
I've tried adding the DNS server IP addresses (that get given out when it connects to the VPN) to it's list of available DNS servers through tcp/IP config, but still no luck.
The annoying this is that if I connect to the VPN on another computer - say my desktop machine, I can connect to both the SQL server (through SSMS) and the MySql server (through Toad for MySQL).
So I guess the question is, without writing a console app to query the SQL database and then add the results of that query in to the MySql databse, or get SQL to spit out the insert query (in text form) to then run in to the MySql database (there's 350000 rows), is there another, more tidy and clean way to achieve this? This is really a one-off exercise.
Thanks for your help in advance.
Export the data from the MS SQL server in CSV file (or SQL script) and import it into the MySQL server.
If it is only specific columns that you want to update then export oly them plus the primary key (if you have one) to a CSV file and then do some text replacement in order to build a update queries out of the data.

No access to tables remote MySQL database

I'm trying to link in MS Access to the tables in a MySQL database on a remote computer. I'm using a system DSN (ODBC), but when I try to link to the tables (Link Tables dialog) the dialog is empty. No error message, just a empty list. I'm sure I've a connection because after changing the Limit Connectivity to Hosts Matching field in the MySQL security tab (MySQL Workbench) from "%" to only "localhost", I get an error. All fields in the Administrative Roles tab are checked!
A few questions for you to consider:
Is that DSN associated with the database schema which includes the tables you want linked?
Does the DSN work in the opposite direction ... can you export an Access table to MySQL using that DSN?
Are there any provisions in MySQL to monitor client connections, requests, and so forth?
I'm basically grasping at straws on this one. But I'm wondering if maybe the DSN is functional, but perhaps not pointing at the MySQL location which includes the tables you want.
Point #2 should tell you whether the DSN is working at all. If you can export, find out where the exported table wound up in MySQL and compare that with the location of your other tables.