Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 012010
 

MySQL binary log files take all of my disk space

Answer:

If you have enabled binary log in your MySQL server, most likely you are using the replication feature. You don't need to keep the binary log forever, so in the my.cnf, add the line

expire_logs_days = 10

So your MySQL server (master) would keep at most binary log for 10 days. (Notes: you might need to adjust this value, make sure your MySQL slave is able to catch up the updates within 10 days)

However, if you are not using replication, you can consider disable the binary log, e.g. edit the my.cnf, comment out the "log-bin"

# log-bin

Mar 022009
 

How to rename table in MySQL

Answer:

Login into MySQL shell, and enter the following SQL

mysql> USE my_db;
mysql> RENAME TABLE old_table TO new_table;
Query OK, 0 rows affected (0.00 sec)

That's all what you need.

Feb 132008
 

Export MySQL database as CSV file

Answer:

Export MySQL database CSV file can be done with the mysqldump command.

E.g.

# mysqldump my_db --fields-terminated-by=',' --fields-enclosed-by='"' --fields-escaped-by='\' --lines-terminated-by='\n' --tab /tmp

You will find the whole database my_db is exported under the /tmp folder, in which *.sql files are the table definiation, and *.txt files are the table's content in CSV format.