mysql ver is 5.0.67
my trigger code is :
DELIMITER //
CREATE TRIGGER upd_price BEFORE UPDATE ON product_price
FOR EACH ROW BEGIN
INSERT INTO update_price_log (product_id, product_price_old, product_price_new) values(OLD.product_id, OLD.product_price, NEW.product_price);
END
//
DELIMITER ;
error is:
#1227 - Access denied; you need the SUPER privilege for this operation
my server, is not cpanel! it is : DirectAdmin Web Control Panel.
how can i create SUPER privilege and create my trigger?
To do this, issue the following command in your MySQL client: GRANT TRIGGER ON <mahara_db_name>. * TO '<mahara_db_user>'@'localhost'; Replace <mahara_db_name> with the name of your Mahara database, and <mahara_db_user> with the database user.
To create a trigger or drop a trigger, use the CREATE TRIGGER or DROP TRIGGER statement, described in Section 13.1. 22, “CREATE TRIGGER Statement”, and Section 13.1. 34, “DROP TRIGGER Statement”. Here is a simple example that associates a trigger with a table, to activate for INSERT operations.
Privileges for database objects such as tables, indexes, views, and stored routines can be granted for specific objects within a database, for all objects of a given type within a database (for example, all tables in a database), or globally for all objects of a given type in all databases.
In MySQL, the user permissions are granted to the MySQL user account which determines operations that can be performed in the server. These user permissions may differ in the levels of privileges in which they are applied for several query executions.
Another way to create trigger without SUPER privilege by adding the following line to my.cnf or my.ini log_bin_trust_function_creators = 1
I tried to give SUPER privilede on database.table level, but it fails, so I did
grant super on *.* to 'my_user'@'localhost';
then created my triggers. But don't forget to revoke it
revoke super on *.* from 'my_user'@'localhost';
Because it's a dangerous privilege to leave it granted in internet database
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With