Skip directly to content

mySQL

on Sat, 04/02/2011 - 10:08

Dump all databases

MySQL :: MySQL 5.0 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program

You can dump all databases by:

# mysqldump [options] --all-databases An example would be:

# mysqldump -u root -p --all-databases > all_dbs.sql If you just want to dump several databases into one file: # mysqldump [options] --databases db_name1 [db_name2 db_name3...]

An example would be:

# mysqldump -u SomeUser -p --databases mydb1 mydb2 mydb3 > myDbs.sql
 

Import database

mysql -p -h DBSERVER dbname < dbname.sql
 
Or with charset: mysql -uUSERNAME -pPASSWORD --default-character-set=utf8 USER_DATABASE < backup.sql

Repair table

MyIsam tables can be corrected with:

REPAIR TABLE <table>;  or for more options, with  myisamchk --safe-recover 

Read more on:  http://dev.mysql.com/doc/refman/5.0/en/repair-table.html  and http://dev.mysql.com/doc/refman/5.0/en/myisam-table-maintenance.html

To sum up: login to your MySQL server with

mysql -uroot -p <skriv credentials>

use <database>

CHECK TABLE tbl_name [, tbl_name] ... [option] ... || eller myisamchk table (http://dev.mysql.com/doc/refman/5.0/en/myisamchk.html)

 

type: 
Tags: 

Post new comment