Dump AWS RDP Server db data - mysql

I have a AWS Production server with RDP database.
I am accessing db in remote desktop using Putty through this command -
mysql -h ----------.rds.amazonaws.com -P (port number) -u (master username) -p (master password)
Now I want to dump the server db into a file. In my local MySQL I use to do it through -
mysqldump -u (user name) -p (password)
But in case of live server I tried this command -
mysqldump -h --------.rds.amazonaws.com -P (port number) -u (master username) -p
this is not working. How can I dump server RDP db.

Correct command is -
mysqldump -h --------.rds.amazonaws.com -P (port number) -u (master username) -p (database name) > (.sql file name).
This way we dump the server DB in a file.
Remember to move on .sql file location before running this command in putty.
Thank you.

Related

mysqldump via cmd syntax for dumping remote database

I have Mysql installed on my local PC and want to use mysqldump on my local pc to dump a remote database. So I open CMD and run the following command:
mysqldump -P 3306 -h 12.43.33.43 -u admin -p myDatabase > mydb.sql
So in the next line it should ask for my password? but instead i get the response 'Access is denied'. Am i missing something here?
ps.
If I try the following:
mysqldump -P 3306 -h 12.43.33.43 -u admin -p myDatabase
it will successfully ask for my password and start printing the dump in cmd, but this is no good as i need the response saved in a file.
I only wanted to know if you could connect.
The command is
mysqldump -P 3306 -h 12.43.33.43 -u admin -p --databases myDatabase --result-file=mydb.sql
As the connection is not secure, you send your credentials like a postcard, so that every one can read it.
Besides that having your server exposed to the internet, is very dangerous and can come to a disaster, so reconsider your security strategy and allow only access via ssh.

How to mysqlimport a local export to remote mysql server?

I have a local mysql dump that I want to copy-insert into a remote db:
mysqlimport --host=192.168.xxx.xxx --user=username --password=password remote_table /tmp/export.txt
Result:
mysqlimport: Error: 1290, The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
So how can I tell my remote mysql server to accept imports from remote machine?
i) take mysql dump as follows
mysqldump -u user -p db-name > db-name.out
ii) Copy db-name.out file using sftp/ssh to remote MySQL server:
scp db-name.out user#remote.box.com:/remoteBoxDirectory
iii)Restore database at remote server (login over ssh):
mysql -u user -p db-name < db-name.out
or
mysql -u user -p 'password' db-name < db-name.out

mysqldump via SSH to local computer

I have an SSH access to production server of the Rails app.
I want to make a mysqldump of production database to my Mac. Please help me to achieve this.
Direct method to dump mysql data from remote server to your local computer is:
ssh root#ipaddress "mysqldump -u dbuser -p dbname | gzip -9" > dblocal.sql.gz
Or
ssh -l root ipaddress "mysqldump -u dbuser -p dbname | gzip -9" > dblocal.sql.gz
Both command does the same work.
If you have password for ssh and database access there will two prompt for password or if you have no password for ssh then you will be asked to enter you database password.
Similarly, if you are using key from aws or cloud other service you can incorporate the key in the command as:
ssh -i key.pem root#ipaddress "mysqldump -u dbuser -p dbname | gzip -9" > dblocal.sql.gz
Connect to server via ssh: ssh remote_username#remote_host
Go to 'current' folder
Make a dump: mysqldump -u username -ppassword -h host database > dump.sql
Disconnect from server
Copy a dump.sql file to local computer: scp remote_username#remote_host:/path/to/dump.sql /Users/YourName/Documents/dump.sql
Connect to server via ssh again and go to 'current' folder
Remove dump.sql file: rm dump.sql
I couldn't get the other ones to work.
This is the solution I found for linux:
ssh username#ipadress "mysqldump -u USERNAME -pPASSWORD DB_NAME " > ~/dump.sql
This will prompt you to enter a password for your ssh server, and then dumps the database to the specified location on the SSH server.

How to backup MySQL database on a remote server?

I have a MySQL database existing on a remote server. I only have sql connection privilege. I don't have FTP access to the server, and I need to do a complete dump of the database. I have tried mysqldump, but the issue is that it is creating the output on the server and as I don't have FTP I can not get the output from the server.
How can I do a clean backup and get the dump in my local machine(of course, the backup should be restored in my local machine)?
You can specify the server name as an option to mysqldump:
mysqldump --host servername dbname > dbname.sql
mysqldump --host hostaddress -P portnumber -u username -ppassword dbname > dbname.sql
Normally the remote port of MySQL is 3306. Here is an example:
mysqldump --host 192.168.1.15 -P 3306 -u dev -pmjQ9Y mydb > mydb.sql
You can use the MySQL workbench http://www.mysql.com/products/workbench/, which can backup directly to a local folder through a user-friendly interface
mysqldump.exe locks tables by default, so other SQL actions are not possible during a dump. Without locking any tables, use the following syntax to backup a complete remote db and dump everything on your local machine:
mysqldump -u username -p --single-transaction --quick --lock-tables=false -h ipaddress myDB > backup.sql
Change username into your own username, change ipaddress into the remote ip address, and myDB to the actual database you want to backup. This will prompt you for your password. Once provided, the dump starts.
I use SQLyog for this where we can connect to the remote server and take a back up with this tool.
If the server admits PHP, you can upload and try Adminer. I like it as a PHPMyAdmin replacer, and you can create backups with it!

Copying Mysql data to a remote server

I am running mysql server on my computer.I would like to copy the databases i have created and their tables to a remote server,and that is my website.Is there a software(a windows software) that can help me copy my databases to a remote server?.
If you have external access to both mySQL servers, HeidiSQL is a great Windows GUI for mySQL with a good export function.
Alternatively (also needing external access), install the mySQL binaries on your machine and do a simple
mysqldump -h hostname_source -u username -p databasename > dump.sql
mysql -h hostname_target -u username -p databasename < dump.sql