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 022010
 

How to create a new MySQL user?

Answer:

1. Enter the MySQL shell using root account

mysql -u root -p mysql

2. Execute the SQL like the followings

GRANT ALL PRIVILEGES ON db1.* TO 'user1'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

3. Now try to login using user1 account

mysql -u user1 -p db1

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.