MySQL: ย้ายข้อมูลระหว่างฐานข้อมูล
วิธีการง่ายๆ ในการย้ายข้อมูลระหว่าง database สามารถทำได้ดังนี้
- สร้างฐานข้อมูลใหม่ เช่น new_database
- ใช้คำสั่ง mysqldump ดังนี้
#mysqldump -uroot -p old_database | mysql -uroot -p -D new_database
Popularity: 1% [?]
วิธีการง่ายๆ ในการย้ายข้อมูลระหว่าง database สามารถทำได้ดังนี้
Popularity: 1% [?]
หลังจากทำการ upgrade MySQL server ควรจะใช้คำสั่งต่อไปนี้
#mysql_upgrade -uroot -p
และ
#mysqlcheck -uadmin -p --auto-repair --check --optimize --all-databases
เพื่อตรวจสอบว่ามีปัญหาระหว่างการ upgrade หรือไม่ เนื่องจากผมเจอปัญหาที่ดูเหมือนว่าฐานข้อมูลหายไป เมื่อตรวจสอบแล้วก็พบว่าฐานข้อมูลยังอยู่ แต่ถูกเติมข้างหน้าด้วย #mysql50#
If you have databases or tables from a version of MySQL older than 5.1.6 that contain special characters and for which the underlying directory names or file names have not been updated to use the new encoding, the server displays their names with a prefix of #mysql50# in the output from INFORMATION_SCHEMA tables or SHOW statements.
ที่มา http://dev.mysql.com/doc/refman/5.1/en/identifier-mapping.html
Popularity: 1% [?]
ผมใช้ innoDB ใน MySQL แล้วเจอข้อความ error นี้
Lock wait timeout exceeded; try restarting transaction
วิธีแก้ปัญหาที่ทำตอนนี้คือเปลี่ยนกลับไปใช้ MyISAM เหมือนเดิมก่อน
Popularity: 1% [?]

ในกรณีที่ต้องการกำหนดค่า auto increment ใหม่ สามารถทำได้ตามรายละเอีดข้างล่างนี้
I have a database table with a auto increment column for primary key. As the records being add and delete many times, the auto increment value will keep increasing.
Problem One:
If I have entered 10 records, and deleted 9th, 10th records. The next auto increment value will be 11, not 9.
Solution:
Run a query:
ALTER TABLE tablename AUTO_INCREMENT = 1
This will reset the next auto increment value to current largest value in the auto increment column + 1. So, the auto increment value of next inserted record will start from 9.
Problem Two:
If I have entered 10 records, and deleted center records – 4th, 5th. I want to insert next record as 4th not 11th.
Solution:
Run the following query:
SET insert_id = 4;
INSERT INTO tablename VALUES ('blah', '...');
This will add the next record into record 4th.
The SET insert_id = #(where # is the next auto increment value you want to use) will reset the next auto increament value, the next query(INSERT) you run will use your choice of value.
Note: only effective for the immediate next query, one time.
Source: http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/
Popularity: 1% [?]
ตัวอย่าง Query การจัดลำดับของข้อมูล
SET @rank=0; SELECT @rank:=@rank+1 AS rank, id, name, subject FROM mca ORDER BY id DESC;
ที่มา: http://www.roseindia.net/sql/mysql-example/mysql-rank.shtml
Popularity: 1% [?]