MySQL

From Useful Things
Revision as of 03:02, 26 June 2014 by Milosivanovic (talk | contribs) (After update)
Jump to: navigation, search

User management

Adding a user

grant all privileges on {database_name}.* to {database_user}@'%' identified by 'their_password';

Revoking privileges

revoke usage on {databse_name}.* from {database_user}@'%';

Removing a user

drop user {database_user}@'%';

Triggers

After update

create trigger {trigger_name} after update on {table_name}
	for each row begin
		insert into {new_table} (col1, col2, col3) values (OLD.col1, NEW.col2, OLD.col3)
	end