Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
546

If you are dumping tables t1, t2, and t3 from mydb mysqldump -u... -p... mydb t1 t2 t3 > mydb_tables.sql If you have a ton of tables in mydb and you want to dump everything except t1, t2, and t3, do this: DBTODUMP=mydb SQL="SET group_concat_max_len = 10240;" SQL="${SQL} SELECT GROUP_CONCAT(table_name separator ' ')" SQL="${SQL} FROM information_schema....


271

If you're just importing from a dump file from the CLI on *nix, e.g. mysql -uxxx -pxxx dbname < /sqlfile.sql then first install pipe viewer on your OS then try something like this: pv sqlfile.sql | mysql -uxxx -pxxxx dbname which will show a progress bar as the program runs. It's very useful and you can also use it to get an estimate for mysqldump ...


85

All Data is InnoDB This is what will give you an exact point-in-time snapshot of the data: mysqldump -uuser -ppass --single-transaction --routines --triggers --all-databases > backup_db.sql --single-transaction produces a checkpoint that allows the dump to capture all data prior to the checkpoint while receiving incoming changes. Those incoming changes ...


85

Percona's Vadim Tkachenko made this fine Pictorial Representation of InnoDB You definitely need to change the following innodb_buffer_pool_size = 4G innodb_log_buffer_size = 256M innodb_log_file_size = 1G innodb_write_io_threads = 16 innodb_flush_log_at_trx_commit = 0 Why these settings ? innodb_buffer_pool_size will cache frequently read data ...


73

Rather than killing the process, it would be safer if you did it within MySQL: $ mysqladmin processlist -u root -p Enter password: +-----+------+-----------+-------------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+------+-----------+-------------------+...


72

A note to expand on the answer by RolandoMySQLDBA. The script he included is a great approach for including (and table_name in) or excluding (and table_name NOT in) a list of tables. If you just need to exclude one or two tables, you can exclude them individually with the --ignore-table option: mysqldump -u -p etc. --ignore-table=Database.Table1 --ignore-...


67

The architecture of InnoDB demands the use of four basic types of info pages Table Data Pages Table Index Pages Table MetaData MVCC Data (to support Transaction Isolation and ACID Compliance) Rollback Segments Undo Space Double Write Buffer (background writing to prevent reliance on OS caching) Insert Buffer (managing changes to non-unique secondary ...


65

I recently moved a 30GB database with the following stragegy: Old Server Stop mysql server Copy contents of datadir to another location on disk (~/mysqldata/*) Start mysql server again (downtime was 10-15 minutes) compress the data (tar -czvf mysqldata.tar.gz ~/mysqldata) copy the compressed file to new server New Server install mysql (don't start) unzip ...


58

You can let mysqldump create the dump in such a way that it does not create or select the database. EXAMPLE : You are dumping the database db1 and loading it into database db2 This will put in the CREATE DATABASE and the USE commands in the dump mysqldump -u... -p... --routines --triggers --databases db1 > /root/db1.sql This will not put in the ...


52

Based on this blog post http://ilikekillnerds.com/2014/08/fixing-sequel-pro-sql-encoding-error-for-imported-sql-files/ When importing your database dump, you need to select Western (Mac OS Roman) as the encoding format for the file to import without issue.


49

Export: mysqldump -u username –-password=your_password database_name > file.sql Import: mysql -u username –-password=your_password database_name < file.sql


35

Easier to use the --single-transaction switch: mysqldump --single-transaction -u username -p db > db.sql


33

What I think is that the database you are trying to dump contains procedures/methods that were defined by a user while logged in as root@'foobar'. Now the solution is that you have to replace the definer's for that procedures/methods then you can generate the dump without the error. you can do this like .. UPDATE `mysql`.`proc` p SET definer = 'root@...


33

You need to collect all the database names into a space delimited list. Use that for mysqldump MYSQL_USER=root MYSQL_PASS=rootpassword MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}" # # Collect all database names except for # mysql, information_schema, and performance_schema # SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN" ...


29

When you have more than a few tables it is much better running something like this: mysql databasename -u [user] -p[password] -e 'show tables like "table_name_%"' | grep -v Tables_in | xargs mysqldump [databasename] -u [root] -p [password] > [target_file] Or somethink like this: mysqldump -u [user] -p[password] databasename `echo "show ...


29

Best Practices to take MySQL server backup: MySQL Replication Setup Replication in MySQL. You will have to setup Master and Slave server. All read-writes to the DB could go to your Slave Server. Advantage of having Replication is you can take a backup from your slave server without interrupting Master server, Your application will continue to work on ...


29

You are going to find this shocking, but you only need one major option : --opt What is --opt ? This option, enabled by default, is shorthand for the combination of --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset. It gives a fast dump operation and produces a dump file that can be ...


28

If you've already started the import, you can execute this command in another window to see the current size of your databases. This can be helpful if you know the total size of the .sql file you're importing. SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MiB" FROM information_schema.TABLES GROUP ...


28

You can also import an .sql file as an already connected user to the database manner : mysql> use your_database_name; mysql> source file.sql;


28

Please run this query: SELECT Data_BB / POWER(1024,1) Data_KB, Data_BB / POWER(1024,2) Data_MB, Data_BB / POWER(1024,3) Data_GB FROM (SELECT SUM(data_length) Data_BB FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','performance_schema','mysql')) A; This will give you a ballpark figure. The column index_length is ...


25

I know it's really late, but I found this question when I faced the same problem. So, in case anyone need, I found two possible solutions: your user misses the LOCK privilege, so you should ask your database administrator to grant it to you run the same mysqldump command, simply adding the --single-transaction flag, eg. mysqldump --single-transaction -u ...


22

The recommended way to back up RDS is with automatic backups and DB snapshots. DB snapshots are basically the same as EBS snapshots, which are stored in S3 behind the scenes, but are only available within the same region. If you need cross-region fault tolerance (good plan!), there is no way to restore your data in another region without doing it "the ...


22

Take these some points in your consideration they may help you in case of generating the dump and restoring it. Use Extended inserts in dumps. Dump with --tab format so you can use mysqlimport, which is faster than mysql < dumpfile. Import with multiple threads, one for each table. Use a different database engine if possible. importing into a heavily ...


21

No mysqldump -all-databases does not include all objects mysqldump --help -A, --all-databases Dump all the databases. This will be same as --databases with all databases selected. So mysqldump with --all-databases only dumps all the databases. In order to migrate all the databases to a new server, you should take a complete ...


19

You can dump database with SequelPro (Mac OSX) with File > Export (⇧⌘E) option.


18

The reference to --binary-mode (introduced in MySQL 5.6.3) is probably a distraction. It doesn't sound like you're dealing with a mysqldump output file, there. Try the file utility. shell> file dumpfile.sql dumpfile.sql: ASCII text If you don't get the ASCII text response, you're dealing with either something that isn't a dump file from mysqldump at ...


17

The quickest solution would just be to re-create the definer so it does exist, as long as it doesn't create any conflicts with existing users. CREATE USER 'root'@'foobar';


17

When you execute a mysqldump of a single database, all tables are dumped in alphabetical order. Naturally, the reload of the mysqldump into a database would also be in alphabetical order. You could just do a SHOW PROCESSLIST; and find out the DB Connection running the mysqldump. When the dump is reloaded, the DB Connection will vanish. If you want to know ...


16

In General if you have the credentials for accessing MySql from Machine B. You should have MySQL user name , host name and Password.Then You can write the Command for taking backup On Machine B Write mysqldump -h Your_host_name -u user_name -p password --all-databases > backup.sql If You Face issues there may be some network issue try some things as ...


16

Back on Dec 16, 2011, I answered the question How do you mysqldump specific table(s)? I collected all tables not including a certain set of table names. Using the same principles, you could have collect all the database names from the metadata table information_schema.schemata that you want mysqldump'd, create a query to return that list, then use that ...


Only top voted, non community-wiki answers of a minimum length are eligible