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';
Related
I created a new Mysql database in Amazon RDS, and on my local computer I get access through the console
mysql -u username -p -h test.c2nfdg67dbdpb.us-east-1.rds.amazonaws.com
Now I try to connect via Aws Lamda using python and pymysql module
rds_host = "test.c2nfdg67dbdpb.us-east-1.rds.amazonaws.com"
name = 'username'
password = 'pass'
db_name = 'dbtest'
conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5)
and got an error ERROR] 2019-11-20T14:30:05.261Z 7b1ed2e0-03ba-4c62-9525-22d84582f (1049, "Unknown database 'dbtest'")
It seems strange that I don't use the database name at all through the local console and I get access.
p.s.I run show databases; on local console and cant see dbtest in databaselist. I was confused because when I created the new database, I entered a name, but only default databases are listed. What am I connected to then?
p.s.s
hm why DB name is undefined ?
Your code explicitly tries to connect a specific database named dbtest. It will either connect to this database or fail, contrary to your mysql client which can connect without a database selection. Clearly, the database is missing, since you verified that show databases results does not include dbtest.
Then only possible explanation is that the database was never created.
The RDS console provides the ability to create a database with default settings. That's the way I used it. But no physical database is created, only database instances.
I can't found a way to add a new database to the created instance. Now, after a few hours of troubleshooting, I recreated the new database without using the default settings and there was a point - database name entry. I added this name and everything worked out.
But here's what I don't understand is why AWS added a quick creation way, which in the end doesn't actually create a database that you can join.
If you have created the database in Amazon RDS and are able to connect to it from your local computer, it may be a connection/permission issue with your lambda. Your Lambda function may be inside a VPC subnet with no internet access. Either pull it out of the VPC or grant internet access to the Lambda function like this:
https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/
However, if your Lambda function will be communicating with RDS instances, you should consider doing this via private channels for security purposes.
Update
A third possibility is that the database in question doesn't exist even though the asker implies that there was a successful connection to the database from his/her local computer.
Deployed a new version of our app on heroku and migrated over database from previous free jawsdb instance. However now every time user signs up gives
(Mysql2::Error: INSERT command denied to user <username for instance
what have i missed
migrated using a dump and re-import using mysql command line. eye balled exported data and it seems to be there (user emails etc)
all config vars look ok (DATABASE_URL is mysql2...)
i can login to the database via the url
I have not had to grant access or anything like that before, anyone come across this?
thanks
Ben
My guess is they disabled your INSERT grant because you have reached your max Storage Capacity for your plan.
To validate this is a permissions problem, log into a MySQL prompt with the user the app is running as, and enter this query:
SHOW GRANTS;
It probably list many, but no INSERT.
See this link. As explained in given link, jawsdb preliminary plan does not give you permission to add a new database. You are provided with one schema with some random name and you have to work with that only.
Check your migration
e.g. Make sure the database name matches.
For me, I got the same error as OP when trying to migrate my data. This was a fresh account with only a 50kb'ish database; nowhere close to the free-plan 5mb limit.
In my SQL export statement, my local database name is being used, however the remote MySQL (ie JawsDB) service auto-generates a db name, which will obviously not be the same. Simply used find-replace to change the database name to match remote; everything works.
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
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.
$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.