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
หากไม่มีเมนูจัดการสามารถใช้วิธีการนี้เปลี่ยนได้ วิธีแก้ปัญหาทีม TS ส่งให้ lv2 วิธีแก้ปัญหาทีม SYSNOC หรือ ITS 1. Dump mysql database จาก character เดิมไปเป็น character ใหม่ cd /var/lib/mysql/ # export DATABASE="adminzil_ziltech" # cp -a ${DATABASE} ${DATABASE}40 # mysqldump --default-character-set=tis620 --skip-set-charset ${DATABASE} > ${DATABASE}.sql # ถ้า dump มาแล้ว อ่านไทยไม่ออกลอง # mysqldump --default-character-set=latin1 --skip-set-charset ${DATABASE} > ${DATABASE}.sql # replace tis620 utf8 -- ${DATABASE}.sql # mysql --execute="DROP DATABASE ${DATABASE};" # mysql --execute="CREATE DATABASE ${DATABASE} CHARACTER SET utf8 COLLATE utf8_general_ci;" # mysql --default-character-set=utf8 ${DATABASE} < ${DATABASE}.sql export DATABASE= 2. แก้ไขเว็บไซต์ให้ connect database โดยใช้ character set utf8 โดย search หาจุด ที่มี code mysql_connect หรือ mysql_pconnect และ เพิ่ม code mysql_query("SET character_set_results='utf8'"); สำหรับ ADODB เวลา query ให้ใช้ $sql = "SET character_set_results='utf8'"; $conn->Execute("$sql"); หรือใช้ SET CHARACTER ก็ได้
Innodb ดีกว่า MyISAM เกือบทุกอย่าง ยกเว้น การ import และ export data จะช้าเนื่องจากมีการ lock data ในระดับ row (MyISAM ทำในระดับ table เท่านั้น) Innodb เหมาะกับเว็บใหญ่คนเข้าใช้งานเยอะ ๆ ทำงานได้เร็วกว่า Administration เวลาย้ายระหว่าเครื่อง ไม่สามารถ copy *.ibd files ไปที่เครื่องใหม่ได้เลย. The files contain some ID numbers that would have to be translated. Also, the redo log (ib_logfile*) contain references to the *.ibd files. ต้อง dump database และ import กลับเข้าไปใหม่เท่านั้น วิธีแก้ปัญหาทีม TSส่งให้ lv2 วิธีแก้ปัญหาทีม SYSNOC หรือ ITSRecovery http://forums.mysql.com/read.php?22,34050,52933#msg-52933 if you are not using the [mysqld] option innodb_file_per_table then an InnoDB table consists of the .frm file in the database directory, the table data dictionary entry and data in the ibdata files. If 1. is missing, you can create the table in some other database, and copy the .frm file from there. If 2. is missing, you can simply delete the .frm file manually. After this, you are in a consistent state. --- If you are using innodb_file_per_table then an InnoDB table consists of: the .frm file in the database directory, data dictionary entry in the ibdata files, the .ibd file. If MySQL complains it can't open file x.ibd, that means either 2) or 3) or both are missing. You should look into the .err log of mysqld to determine which is the case. If 1) is missing, do like above. If 2) is missing, then simply delete the .frm file manually (and also the .ibd file if that one exists). If 3) is missing, you should upgrade to a recent 4.1.xx or 5.0.xx version, and simply DROP the table. Earlier versions had the problem that if you did not have the option no-auto-rehash in the [mysql] section of your my.cnf, then dropping a table with a missing .ibd file did not work.