how to migrate the procedures b/w two databases in mysql - mysql

if i have 2 diff database(A&B),now i want to migrate all data (not only the tables, but also include the procedure) from A to B,is there any way to solve this?

There are a few utilities that come packaged with mysql. Have you looked at mysqldump? It allows you to create a backup of a database which you can recreate elsewhere.

As Zach pointed out, mysqldump can handle this. If you would rather a GUI, you could also try Toad. It has a schema compare option that can show you the differences between the two databases and let you choose which tables and routines you wish to migrate.

Related

How to import a MySQLdump into a PostgreSQL database?

I have a MySQLdump generated by PHPMyAdmin, and I need to import it into a Postgresql database, but I dont know if it's even possible. I've seen people recommending pgloader but seens a little confusing on how to do it. Also I'm on windows if its relevant at all.
I only need the tables, so I'm not concerned about the data in the old or in the new database.
It's not that big too, only 84 tables. But big enough for me to write it.
Thank you!
You can use pgloader.
You need to install it, and then run a simple lisp script (script.lisp) with the following 3 lines:
/* content of the script.lisp */
LOAD DATABASE
FROM mysql://dbuser#localhost/dbname
INTO postgresql://dbuser#localhost/dbname;
/*run this in the terminal*/
pgloader script.lisp
And after that, your PostgreSQL DB will have all of the information that you had in your MySQL DB.
There are a lot of resources to do this. None of them are simple.
pgloader which you mentioned is among the many tools listed on this page: https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#MySQL
MySQLdump is supposed to have an option --compatible=postgres but don't rely on that. It makes some changes to its output, but not enough to be fully compatible with PostgreSQL syntax.
Another option is to dump tables to CSV files with mysqldump --tables instead of dumping to SQL format. Then you can bulk-load the CSV files one by one with the COPY statement in PostgreSQL.
If your MySQL database contains views or stored routines (procedures, functions, triggers, or events), then in general those can't be converted by any tool. The PostgreSQL language for stored routines is too different from MySQL. You must just start over and code routines in PostgreSQL that do equivalent logic, but coded in a way more idiomatic for PostgreSQL.

MySQL Replace table from another table

I have 2 active database connections, I need to replace a number of tables from 'connection1' with that of connection2. The structures may, or may not be same, (depending if we make changes to the connection1 table.
I would assume I should do a complete table dump and replace keys where neccesary, but I really have no idea how to do this :)
Any help?
Have a look at Schema and Data sync tools in dbForge Studio for MySQL. It will help you to compare two databases on different servers, map tables and fields, generate and run synchronization script.
I ended up using the build in system command in PHP and mysqldump to first dump the data (export) to a file, then used system() again with mysql to import it into the new table and replace the old one.
Works like a charm :)

Importing records from PostgreSQL to MySQL

Was wondering if anyone had any insight or recommended tools for exporting the records from a PostgreSQL database and importing them into a MySQL database. I believe the table structure is 100% identical.
Thoughts? Thanks!
The command
pg_dump --data-only --column-inserts <database_name>
will generate SQL-standard-compliant INSERT statements with all column names listed and one VALUES clause per INSERT. This is the most portable way of moving data from PostgreSQL to any other SQL database.
Check out SquirrelSQL, it can pump data from one database brand into another via the DBCopy plugin. When the table structures are really identical it works quite well.
There is a ruby app called Taps that will do it. I've used it before with great success:
http://adam.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/

Copy only schema to existing mysql db

I have 2 db mysql at two locations, i need to copy the schema from first to the second one without hurting the data that is already existing in the II location.
Is it possible to achieve this?
Please experts help.
Databases are usually too complex to allow a simple "copy".
Use Toad's database comparison/scripting tools (or something like this: http://adamspiers.org/computing/mysqldiff/) to find the differences, check and run them manually.

MySQL database - backup problem

Hi I need to backup MySQL database and then deploy it on another MySQL server.
The problem is, I need it backup without data , just script which creates database, tables, procedures, users, resets autoincrements etc. ...
I tried MySQL administrator tool (Windows) and UNchecked "complete inserts check box", but it still created it ...
Thanks in advance
use mysqldump with option -d or --no-data
don't forget option -R to get the procedures
this page could help you: http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
From within phpMyAdmin you can export the structure, with or without the data. The only thing I'm not sure of, is wether it exports users as well. If you like, I can test that tomorrow morning. It exports users too. You can check all sorts of options.
(source: obviousmatter.com)
According to the page, there isn't a good way to dump the routines and have them easily able to be recreated.
What they suggest is to dump the mysql.proc table directly. Including all the data.
Then use your myback.sql to restore the structure. Then restore the mysql.proc table with all of its data.
"... If you require routines to be re-created with their original timestamp attributes, do not use --routines. Instead, dump and reload the contents of the mysql.proc table directly, using a MySQL account that has appropriate privileges for the mysql database. ..."