Migrating local database to Azure ClearDb through mySQL Workbench - mysql

I have been trying this but no success, i get to this stage and no further.

If you need to migrate from local database to azure cleardb, simply use the mysqldump utility in conjunction with the mysql command line client. For example:
mysqldump --single-transaction -u (old_database_username) -p -h (old_database_host) (database_name) | mysql -h (cleardb_host) -u (cleardb_user) -p -D (cleardb_database)
But if you insist on using MySQL Workbench then this might be of help -
http://nullsession.com/2014/02/04/downgrading-you-cleardb-mysql-database-in-azure/

Related

Is there any way to connect mysql server using ansible and perform operations like execute .sql files and various lind of mysql dump and restore?

I am trying to connect mysql db using ansible but unable to login, how can I able to connect my mysql database using ansible and do operation like database dump- data restoration and .sql file execution.
you can just run it as a shell command in ansible:
mysql -u USER -p PASSWORD -h MYSQLSERVERNAME -e 'select * from foo...' database-name
mysql -u USER -p PASSWORD -h MYSQLSERVERNAME database-name < database_name.sql
see here, similar question with playbook snippet

my database is in remote server, is it possible to execute queries on dos prompt for remote database

Is it possible to execute queries on dos promp for a remote database?
I assume by "dos prompt" you mean from the MySQL command line tool. Yes, it's possible. Here is an example call:
mysql -u[user] -p[password] -h [hostname] -D [database] -e "select * from my_table"
or if you want to just execute a script file, you would do something like this:
mysql -u -p -h remote.host database < yourfile.sql
You need to have mysql installed locally on your windows machine from which you can run something like:
/path/to/mysql -h hostname -u username -p password -D database -ss -e "select stuff from thing;"
To install mysql on your windows machine you can take a look at this related question:
MySQL command line client for Windows

importing mysql database to RDS

I am trying to dump my local mysql database data to an RDS database. I use the following command in windows command:
mysqldump -u <username> <localdbname> --single-transaction --compress --order-by-primary
-p<localdbpassword> > mysql -u <rdsusername> --port=3306 --host=<host> -p<rdspassword>
I noticed that I get a database doesn't exist when the name of my local database and rds database differ. But when they have the same name, this command runs but nothing happens. How should I change it?

Importing sql file into AWS RDS

Currently I have an EC2 Instance and a RDS (mysql) instance. I exported my database from my local workstation and uploaded it to my EC2 instance and put it in my ec2-user home directory.
I log into the EC2 instance and run this command in the same directory as my projectname.sql file which in this case would be substituted for "backupfile.sql" in the command. After running this command my site was able to successfully connect to the database. I knew this because all my errors on my site disapeared. The issue now is that my tables did not seem to upload.
mysql -h host.address.for.rds.server -u rdsusername -p rdsdatabase < backupfile.sql
Running this command:
mysql -h host.address.for.rds.server -P 3306 -u rdsusername -p
With my correct credentials logs me in to the rds server. I then run:
use databasename
show tables
But no tables are shown.
My end goal is to get my localhost database onto AWS RDS by uploading a sql file. If there is an easier way please let me know!This is my first time setting up AWS and these road blocks are killing me.
I use the third party product SQLyog to replicate my database into AWS. It allows you to have connections to multiple databases at the same time and copy between them. In order to set up a connection to your AWS instance you will need the .pem file on your local machine and have to enable MySQL/Aurora in your Security group on EC2. There is a some more information here. Once it is set up it is extremely easy to copy databases or individual tables.
From the aws documentation
sudo mysqldump -u <local_user> \
--databases world \
--single-transaction \
--compress \
--order-by-primary \
-p <local_password> | mysql -u <RDS_user_name> \
--port=3306 \
--host=hostname \
-p <RDS_password>

Extracting a remote MySQL Database without MyODBC?

Is there a way to get a MySQL Dump of a database that is not stored locally. I have the connection string to the database located on another server, but it doesn't seem like MySQLDump wants to do anything if the server is remote.
MySQLDump has a -h parameter to connect to a remote host.
First try the mysql client application:
mysql -h your.server.com -uYourUser -pYourPass
If that works, use the same format for MySQLDump
mysqldump -h your.server.com -uYourUser -pYourPass --all-databases
Edit for ajreal:
By default, mysqld (the MySQL server) will run on 3306, and mysql (the client application) will connect using that port. However, if you changed your configuration, update your command accordingly. For example for port 3307, use
mysql -h your.server.com -P 3307 -uYourUser -pYourPass
Check your MySQL configfile to see how you can connect to your MySQL server.
Here is example, how to extract mysql db named 'abc123' direct to zip, w/o super big text dump file on disk.
mysqldump -u root --opt --databases abc123 | gzip > /tmp/abc123.export.sql.gz