สาเหตุ เกิดจากการย้าย server แล้ว chatset ผิดปกติจะเกิดจากเดิมใช้ latin1 แล้วมาใช้ utf8 หรือ tis620dump database จากเรื่องเดิมลองเปิดไฟล์ที่ dump มาว่าอ่านจาก terminal อ่านภาษาไทยได้หรือไม่ปกติจะอ่านไม่ได้import เข้า mysql ของเครื่องตัวเองก่อน ปกติจะเป็นตัวยึกยือ แต่ไม่ใช่ ??? ถ้าดูจาก phpmyadmin วิธีแก้ปัญหา 1. mysqldump -v -h localhost -u root -p --default-character-set=utf8 --skip-set-charset thaiphuk_pro > thaiphuk_pro.sql 2. replace utf8 tis620 -- /home/prasit/tmp/smilepet_demo1.sql หมายเหตุ บางครั้งการ import อาจจะมีพวก latin ผผสมไปกับข้อความอีกการ replace อาจจะไม่ได้ผล ผมใช้ Aptana สร้าง Project ขึ้นมา แล้ว นำไฟล์ sql ที่จะ import มาตั้ง charset เป็น TIS-620 แล้วใช้การ copy ข้อความ ไปไส่ไฟล์ใหม่ ที่เป็น utf8 แล้วค่อย import การ import database จากไฟล์ mysql -v --default-character-set=tis620 -h localhost -u root -p smilepet_forums < /home/prasit/tmp/smilepet_forums.sql database ecomsupp_mlm ตอนนี้อยู่บนเครื่อง payap ใช้ phpmyadmin backup แล้วมีปัญหา ภาษาไทย ให้ใช้ mysqldump ไปก่อน root@payap [/home/ecomsupp/database_backup]# mysqldump --default-character-set=utf8 --skip-set-charset ecomsupp_mlm > ecomsupp_mlm_2011_09_22.sql root@payap [/home/ecomsupp/database_backup]# tar -cvzf ecomsupp_mlm_2011_09_22.sql.tar.gz ecomsupp_mlm_2011_09_22.sql
ปัญหา ปัญหา database Innodb error ไม่สามารถเรียกได้ หรือขึ้น error ไม่สามารถเรียกได้ ทางแก้ปัญหา ให้ทำการตรวจสอบได้จาก mysql error log เมื่อตรวจพบว่าเป็นปัญหาที่ Innodb เราจะต้องทำการ export Database ออกมาก่อน แล้วทำการ dump database กลับเข้าไปใหม่โดย 1. ให้ทำการ เพิ่มค่า innodb_force_recovery = 6 ในไฟล์ /etc/my.cnf หมายเหตุ : การกำหนดค่า innodb_force_recovery นี้ มีความเสี่ยงที่จะทำให้ข้อมูลสูญหายได้ โดยจะมีค่าตั้งแต่ 1-6 เราควรกำหนดให้เหมาะสม 2. จากนั้นให้ทำการ restart service mysql 3. ให้ทำการ export all database โดยใช้คำสั่ง Export เพียง 1 Database : mysqldump -u root -p databases > database.sql Export database all : mysqldump -u root -p --all-databases > alldb.sql ถ้า export database ออกมาไม่ได้อาจจะติดที่ tables databases lock ให้ใช้คำสั่ง Export เพียง 1 Database : mysqldump -u root -p database --skip-lock-tables > alldb.sql Export database all : mysqldump -u root -p --all-databases --skip-lock-tables > alldb.sql 4. จากนั้นให้ทำการ ลบค่า innodb_force_recovery = 6 ในไฟล์ /etc/my.cnf 5. จากนั้นให้ทำการ restart service mysql 6. ทำการ import mysql database ที่ทำการ export กลับเข้าไปโดยใช้คำสั่ง Import เพียง 1 Database : mysql -u root -p database < database.sql Import database all : mysql -u root -p < alldb.sql สาเหตุของปัญหา ในการใช้งาน MySQL โดยทั่วไปนั้น มีโอกาสที่จะพบปัญหา database เสียหาย เช่นกรณีไฟดับ Harddisk Drive เสีย หรือระบบหยุดทำงานแบบผิดปกติโดยไม่ทราบสาเหตุ
Dump Database และมีการ Insert Query ช้า ใส่ข้อมูลที่ไฟล .sql ตามข้อมูลด้านล้าง 1.- ใส่ข้อมูลหัวของไฟล์ SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, AUTOCOMMIT = 0;SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS = 0;SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0; - ใส่ข้อมูลท้ายสุดของไฟล์SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;SET AUTOCOMMIT = @OLD_AUTOCOMMIT;COMMIT; 2. ดำเนินการ Dump Databasemysql db_name < file.sql
ใช้ในกรณีที่ไม่สามารถทำผ่าน WHM ได้ วิธีแก้ปัญหาทีม TSส่งให้ lv2 วิธีแก้ปัญหาทีม SYSNOC หรือ ITS* สำหรับ ubuntu ต้อง run "sudo su -" ก่อน 1. Stop mysql server. /etc/rc.d/init.d/mysql stop 2. Start MySQL server but skip grant tables mysqld_safe --skip-grant-tables ตอนนี้น่าจะ start mysql ได้ ถ้าไม่ได้แปลว่า mysql มีปัญหาแล้ว 3. ให้ start อีก session หนี่ง เพื่อทำงานต่อ 4. Connect DB mysql --user=root mysql 5. reset root MySQL password update user set Password=PASSWORD('new-password') where user='root'; flush privileges; exit; เปลี่ยน new-password เป็น password ใหม่ 6. Ctrl+C session เดิม เพื่อ stop mysql 7. Start mysql ใหม่ /etc/rc.d/init.d/mysql start
วิธีแก้ปัญหาทีม TSส่ง lv2 วิธีแก้ปัญหาทีม SYSNOC หรือ ITSตัวอย่างที่พบใน เครื่อง zabbix2.netway.co.th (ใช้ mariadb) 1. performance_schema has wrong structure 130929 22:35:53 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 130929 22:35:53 [Note] Server socket created on IP: '::'. 130929 22:35:53 [ERROR] Missing system table mysql.proxies_priv; please run mysql_upgrade to create it 130929 22:35:53 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist 130929 22:35:53 [ERROR] Native table 'performance_schema'.'events_waits_current' has the wrong structure 130929 22:35:53 [ERROR] Native table 'performance_schema'.'events_waits_history' has the wrong structure 130929 22:35:53 [ERROR] Native table 'performance_schema'.'events_waits_history_long' has …….. 130929 22:35:53 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_instance' has the wrong structure 130929 22:35:53 [ERROR] Native table 'performance_schema'.'events_waits_summary_global_by_event_name' has the wrong structure 130929 22:35:53 [ERROR] Native table 'performance_schema'.'file_summary_by_event_name' has the wrong structure 130929 22:35:53 [ERROR] Native table 'performance_schema'.'file_summary_by_instance' has the wrong structure ….. 130929 22:35:53 [ERROR] Column count of mysql.db is wrong. Expected 22, found 20. Created with MariaDB 50077, now running 5532. Please use mysql_upgrade to fix this error. 130929 22:35:53 [ERROR] mysql.user has no `Event_priv` column at position 29 130929 22:35:53 [ERROR] Cannot open mysql.event 130929 22:35:53 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler. วิธีแก้ไข mysql_upgrade -p 2. --log-slow-queries is deprecated 130929 11:49:08 [Warning] The syntax '--log-slow-queries' is deprecated and will be removed in a future release. Please use '--slow-query-log'/'--slow- query-log-file' instead วิธีแก้ไข edit /etc/my.cnf และเปลี่ยน log-slow-queries="/var/log/mysql_slow_query.log" เป็น slow-query-log-file="/var/log/mysql_slow_query.log" และ restart mysql /etc/rc.d/init.d/mysql restart 3. Error WSREP: Query cache is not supported 130929 23:19:12 [ERROR] WSREP: Query cache is not supported (size=268435456 type=1) วิธีแก้ไข edit /etc/my.cnf และเปลี่ยน query_cache_size=256M เป็น # Query Cache is not supported with wsrep #query_cache_size=256M และ restart mysql /etc/rc.d/init.d/mysql restart