Wednesday, January 18, 2012

Safely rename a database command

 shell> mysqladmin -u root -pXXXX create spm_new
shell> mysqldump -u root -pXXXXX SPM
| mysql -u root -pXXXX spm_new &
 first, create the new database (with no tables)
 secondly, use mysqldump to dump from the original database to the new db. if you connect remotely into the server. Please do allow the mysqldump process to run in background by adding  "&" 
 

Tuesday, January 10, 2012

MySQL Replication - slave status showing LastSQLError

If you would need to skip the SQL command from reflect into the slave server, do as following

STEPS:
1. mysql> stop slave;
2. mysql>SET GLOBAL sql_slave_skip_counter = 1;
3. mysql> start slave;

you should be able to see the slave process change into healthy state again.

Monday, January 9, 2012

MySQL - ERROR 13 (HY000): Can't get stat of '/mnt/sharing/success_20111201.csv' (Errcode: 13)

I was tried to restore the CSV file into one of my table, however i face the following error

ERROR 13 (HY000): Can't get stat of '/mnt/sharing/<file>.csv' (Errcode: 13)

Follow the following solution to solve your issue,
1. move the file into a location where your "mysql" user have the permission to read and write
2. in your mysql shell ( after you had login MySQL server via mysql client )
  e.g:
  mysql > load data local infile '/tmp/success_20111201.csv' into table `nplay_temp`.`sms_out_message` fields terminated by '\t' optionally enclosed by '"' lines terminated by '\n' (`id`, `nplay_user_id`, `price`, `is_ucs`, `creation_date`, `last_modified`, `wappush_link`, `retry_count`, `msisdn`, `message`, `delivered_time`, `state`, `mcc`, `operator_code`, `service_name`, `action`, `ticket_id`, `scheduled_time`, `short_code`, `charge_msisdn`, `meta_data`)


Thursday, January 5, 2012

to repair a corrupted myisam table

first, to make sure the table not in use.

you may use the mysql client utility ready by mysql server installation "mysqlcheck" to do the repair 
sample command as follow:

shell> mysqlcheck -u <user_name> -p<password> --auto-repair <database_name> <table_name> &