MariaDB/MySql Command
Backup database
Backup database all table
mysqldump --user=username --password databasename> file.sql
Backup database some table
mysqldump --user=username --password databasename table1 table2 > file.sql
Backup database exclude some table
mysqldump --user=username --password --databases db --ignore-table=db.table1 --ignore-table=db.table2 > file.sql
Repair database/table
For InnoDB Tables:
- Restart MariaDB with innodbforcerecovery by edit MariaDB configuration file (e.g., my.cnf or my.ini) and add or modify the innodbforcerecovery option in the [mysqld] section. Start with a low non-zero value (e.g., 1).
- Restart MariaDB. If it fails, increase the value and retry.
- Once MariaDB starts, you can try to dump the data from the corrupted table, drop the table, recreate it, and then restore the dumped data.
- Check and Optimize Tables: - Use mariadb-check -c databasename to check for corrupted indexes. - Run OPTIMIZE TABLE tablename to force a rebuild of the table.
For MyISAM Tables:
Use REPAIR TABLE statement:
REPAIR TABLE table_name;
You can add the FORCE argument to attempt internal repair before rebuilding:
REPAIR TABLE table_name FORCE;
Use myisamchk utility:
myisamchk -r table_name.MYI
Relate topics
- การเก็บ JSON ใน MySQL ด้วย PHP
- Update table with incremented value grouped by column
- ย้ายบ้านให้ MySql
- UPDATE multiple tables in MySQL using LEFT JOIN
- Column value swap
- my.cnf
- Make Ubuntu to be a web server (LAMP)
- Geometric - เก็บพิกัดกันยังไง เรื่องที่ผมยังไม่รู้
- Reset password root ใน mysql
- Sql injection
- MySQL / PHPMyAdmin - Export Table to Server
- How to install Lighttpd+PHP4+MySql5 on Ubuntu 8.10
- Change my life to Ubuntu