แค่เว็บๆหนึ่ง ! ที่อยากเก็บประสบการณ์
Home
 

ปัญหาเรื่อง function บน MySQL 5.x

 
ปัญหาการสร้าง function บน MySQL 5.0 มีคนแนะนำให้ใช้ MySQL 5.1 จนต้องพยายามติดตั้ง FreeBSD และ ติดตั้ง MySQL 5.1 จนสำเร็จ ก็ถึงเวลาทดลองใช้ ผมทดลองใช้ MySQL 5.1 ปรากฎว่าปัญหานั้นก็ยังไม่หาย

error ที่เจอ ประมาณนี้
This function has none of DETERMINISTIC, NO SQL,
or READS SQL DATA in its declaration and binary logging is enabled
(you *might* want to use the less safe log_bin_trust_function_creators
variable)

วิธีแก้ปัญหาก็ตามลิงค์นี้

http://dev.mysql.com/doc/refman/5.0/en/create-function.html
http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html
http://dev.mysql.com/doc/refman/5.0/en/mysql-fix-privilege-tables.html
http://dev.mysql.com/doc/refman/5.0/en/stored-procedure-logging.html

มีคำสั่งที่ต้องใช้

shell> mysql_upgrade -u root -p
shell> mysql_fix_privilege_tables –password=root_password
mysql> SET GLOBAL log_bin_trust_function_creators = 1;

สำเร็จครับ error ที่เจอหายเป็นปลิดทิ้ง ดังตัวอย่าง

################
[root@mysqlserver ~]# ps -aux |grep mysql
mysql   690  0.0  0.1  3456  1408 con- I     7:45AM   0:00.01 /bin/sh /usr/local/bin/mysqld_safe –defaults-extra
mysql   791  0.0  1.2 57904 23896 con- S     7:45AM   0:00.29 [mysqld]
root   1391  0.0  0.1  3308  1108  p0  S+    8:14AM   0:00.00 grep mysql
[root@mysqlserver ~]# mysqladmin -u root password ‘xxxxxxxx’
[root@mysqlserver ~]# mysql_upgrade -u root -p
Enter password:
Looking for ‘mysql’ in: mysql
Looking for ‘mysqlcheck’ in: mysqlcheck
Running ‘mysqlcheck’…
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log
Error    : You can’t use locks with log tables.
status   : OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.servers                                      OK
mysql.slow_log
Error    : You can’t use locks with log tables.
status   : OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Running ‘mysql_fix_privilege_tables’…
OK
[root@mysqlserver ~]# mysql_fix_privilege_tables –password=xxxxxxxx
This script updates all the mysql privilege tables to be usable by
the current version of MySQL

done
[root@mysqlserver ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.1.22-rc-log FreeBSD port: mysql-server-5.1.22

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)

ที่มา  http://freebsd.sothorn.org

Off 

February 25, 2012 This post was written by Categories: เรื่องเล่ารายวัน No comments yet


Top