How do i dump all the tables from a single database in a sql file except for the ones mentioned? - mysql

I wanted to know if it was possible can do a db dump of all the tables in a database, but leaving a couple of tables specified on the command line. this is for mysql. i know there is one for adding specific tables on an sql, but i dont know if you can exclude specific tables. Thanks in advance.

Mysqldump has an --ignore-table option.

Related

How to compare two databases' altered tables

I have inserted new columns in one database, and I now want to add the same type of columns to a second database. I need to know which columns are in the first database that are not in the second. I have many tables in each database that needs column difference comparing. I searched the web and I can only find ways to see the difference of the contents of columns in two tables. I don't need to compare the contents, just different columns in all the tables in each database. Each database has the same tables.
Thanks!
I found that you can do a database dump that just has the structure from phpmyadmin.
Are you doing this manually? You could just use SHOW CREATE to see the structure of the tables, and then something like the diff command in Linux to compare them.
For a commercial product answer: I use Red Gate's SQL Compare which works great. It can compare the entire schema of two databases. It can also update your target database to match your source database.
Use redgate SQL compare to comapre schema of two tables.
sql-dbdiff works well too. Its an open source.

Duplicate MYSQL Database Same Server Without Using mysqldump

I have a large database, "devDB" that I want to duplicate on the same server to become my live database, "liveDB". Can I make a duplicate without using mysqldump? Last time I used mysqldump it took a really long time. Seems like there could be a quicker way if its just a matter of copying the files. Can you create a new database and copy all the tables?
If you don't want to use mysqldump, create you databases/schema,
and copy the tables from one DB to the other:
CREATE TABLE `liveDB.sample_table` SELECT * FROM `devDB.sample_table`;
Michael's answer above is a good idea if you want to put the newDB in the same MySQL instance as devDB. If you want to put liveDB on a separate Instance, you could use mysqldump to "pipe" the output directly into the "source" of liveDB, so that you could avoid Disk I/O. Also to improve performance, you could disable MySQL's binlog on the target DB while Inserting data.

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/

How can I take MySQL dumps with some tables excluded from the database

We have a database in which one specific table gets very large very fast. When taking a dump and then restoring this database on another server, it takes a lot of time due to the large size. I want to exclude this specific table when taking the dump. Any ideas ?
mysqldump has a --ignore-table option, something like:
mysqldump -p -u username nameofdatabase --ignore-table=verybigtable
Use the --ignore-table flag.
--ignore-table=name Do not dump the specified table. To specify more than one
table to ignore, use the directive multiple times, once
for each table. Each table must be specified with both
database and table names, e.g.,
--ignore-table=database.table.
Most graphical clients (like phpmyadmin) give you exclusion options.