If mysql-bin.* files are taking up all the space, you can use the following steps to clear the space:
log in to mysql as root
then run this command to clear all log up until now:
PURGE BINARY LOGS BEFORE NOW();
Or run this if you want to clear it up to certain date:
PURGE BINARY LOGS BEFORE '2010-08-02 22:46:26';
To change the number of date the log retain, say 14 days:
Edit /etc/my.cnf
Add this line: expire_logs_days=14
Restart mysql
Verify it by running this sql:
select @@expire_logs_days;
Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts
Tuesday, December 24, 2013
Backup and restore MySQL database using mysqldump
Backup:
To backup a mysql database, you can use the following command:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
example: mysqldump -u root -ppassword testdb > backup.sql
Restore:
To restore a mysql database, you can use the following command:
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
example: mysql -u root -ppassword testdb < backup.sql
To backup a mysql database, you can use the following command:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
example: mysqldump -u root -ppassword testdb > backup.sql
Restore:
To restore a mysql database, you can use the following command:
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
example: mysql -u root -ppassword testdb < backup.sql
Subscribe to:
Posts (Atom)