Unable to create trigger on mysql system table [duplicate] - mysql

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
mysql: Cant we create triggers on system tables?
We are using MySQL ver 5.1.59 on rhel 6.1 (64 bit). We want to monitor the deletion of databases and for that trying to create a trigger on the db table of mysql database. We are creating the trigger by logging in as root user. the trigger written is as follows:
DELIMITER |
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
TRIGGER `mysql`.`test` BEFORE DELETE
ON `mysql`.`db`
FOR EACH ROW BEGIN
INSERT INTO cescnet.db_monitor (DB_name,user_name,dateandtime,operation_type) VALUES (mysql.db.Db,CURRENT_USER(),NOW(),'Delete');
END;|
But we are getting the error:
Error Code : 1465
Triggers can not be created on system tables
As we are working as root user, we think we have all the permissions on the system. The global privilege for root user from any host including local host includes the SUPER permission. Can anyone help us please?

I'm going to take a wild guess and say the reason you're getting that error message is that triggers can not be created on system tables.
Oh, perhaps I can add "regardless of privileges"

In short : You can not do.
I have also tried things like
See (All) and (Super) Privileges Provided by mySql
After trying all type of privileges like
grant super on *.* to root#localhost
grant all on *.* to root#localhost
I have tried simplest trigger and get same error
Triggers can not be created on system tables
If you found anywhere that triggers can be created on system tables, simply that is wrong

Related

MySQL ERROR 1396 (HY000): Operation DROP USER failed for 'username'#'localhost'

The software im using automatically creates 2 mysql users during installation. Because of a slight issue those users were created wrongly and the Support advised me to remove the users form the database and then recreate them using the installer (theres a separate option to just create the database users).
The two users are 'username'#'localhost' and 'username'#'%' (yes, they have the same username on different hosts..)
My problem is that neither DROP USER 'username'#'localhost'; nor DROP USER 'username'#'%'; work, both throw an ERROR 1396.
My guess would be that it has to do with the user accounts "owning" elements in the database which would be orphaned. Is there a way to get past this and remove the users anyways? (Since they are gonna be recreated in a second?)
Clarification: Im using the mysql root user.
Ergest Basha's suggestion in this comment worked for me:
You could try deleting from mysql database. use mysql; then delete from user where user='username' and host ='localhost';

MySQL SQL> ERROR: Not connected. Problem with creating a MySQL user

I asked this question here an hour ago. I got a message that my question is closed, because it already has an answer here: Create new user in MySQL and give it full access to one database. However, I think this is a mistake because I didn't find anything relevant there! So I'm trying to ask again (hopefully that's okay):
I'm trying to create a database using MySQL.
I understand that I need to create a user to do so, and then I can create a database and use it in my python project. is that correct?
this is what I tried to run in the MySQL Shell:
MySQL JS > \sql
MySQL SQL > CREATE USER 'myname'#'localhost' IDENTIFIED BY 'mypassword';
I wanted to continue with:
MySQL SQL > GRANT ALL PRIVILEGES ON * . * TO 'myname'#'localhost';
but I got this error- ERROR: Not connected
I looked up ways to fix it, but the only way I found was for people who already have a user.
Does anyone know how to fix this? Thank you.

Create user with no privileges in RDS for MySQL fails, error 1396 [duplicate]

This question already has answers here:
Creating A New MySQL User In Amazon RDS Environment
(5 answers)
Closed 7 years ago.
After going through all the motions to create a database instance on AWS using the RDS tool I've been able to access the database through MySQL Workbench. I've used the master username and password chosen on creation of the instance.
However I wish to create new users who have restricted privileges and can't seem to achieve this without returning an error.
As one can see I've tried it through workbench as well as gitbash and recieved the linked errors.
Here's an image of the interface. I've tried creating a user with zero privaleges and still the same error messages. I know the privilege SUPER can't be granted in RDS. Creating the user fails, without any grants.
The database I'm trying to create new users for is empty and I'm currently using the default VPC. Not sure if either of those affect this.
Any help is appreciated!
I haven't set up any EC2 instance or BD security group, not sure if that's also relevant (Even though I intend to setup in a VPC).
This wouldn't be related to security groups. Your RDS instance isn't actually aware of them -- they only control access to the host running the RDS instance at the TCP layer, in the AWS network.
Regarding your issue -- I think what you'll find is that you somewhere along the line actually did manage to create the user:
mysql> CREATE USER 'stackoverflow'#'%';
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE USER 'stackoverflow'#'%';
ERROR 1396 (HY000): Operation CREATE USER failed for 'stackoverflow'#'%'
mysql> CREATE USER 'stackoverflow';
ERROR 1396 (HY000): Operation CREATE USER failed for 'stackoverflow'#'%'
mysql>
To see the user accounts on the server SELECT * FROM mysql.user;.
Note that user 'stackoverflow' and 'stackoverflow'#'%' refer to the same user, where #'%' means the user's login privilege is not restricted by source IP address or host by MySQL (it can and will still be restricted by the security group settings, as I'll show in some more detail, below).
The mysql.user table contains all of the accounts the server knows about. This table (and several other grant tables) can be manipulated manually, but it's best to use the GRANT, REVOKE, CREATE USER, and DROP USER statements.
Potentially helpful later... if you do set up the security group in such a way that you can't connect to the server (because your source IP address isn't permitted) this will not cause any behavior change on the part of MySQL -- your connection will simply time out, never actually reaching the server, regardless of username and password.
It's a common error you'll see entirely too many people making (including here on SO) to start dinking around with permissions on the server, when they encounter this specific problem -- don't do that -- the problem is always one of network connectivity if you see exactly the following behavior:
$ mysql -h my-rds-with-security-group-too-restrictive.jozxyqk.us-west-2.rds.amazonaws.com
ERROR 2003 (HY000): Can't connect to MySQL server on 'my-rds-with...' (110)
ERROR 2003 can mean several things... but the money is at the end of the line. That code (110) at the end is telling you you're never reaching the server -- it's not a permissions issue, if you see this exact code code. Look it up:
$ perror 110
OS error code 110: Connection timed out
(Linux error code 110 shown; Mac is probably the same code, since I suspect it's a standard POSIX error code, while Windows makes up their own. I believe it's 10060 on Windows that conveys the same meaning.)
Looks like a duplicate of this question: Creating A New MySQL User In Amazon RDS Environment
mysql -u [your_master_username] -p -h YOURRDSENDPOINT.rds.amazonaws.com
CREATE USER 'jeffrey'#'%' IDENTIFIED BY 'somepassword';
GRANT SELECT ON [your_database].[some_table] TO 'jeffrey'#'%';

Can I create Trigger on mysql base [duplicate]

I am trying to audit the privilege changes in mysql.user table by writing a trigger on it.
insert trigger: will capture who gave the new permissions and when
update trigger: will capture who changes the privileges from what[old privilege]
remove trigger: will capture who removed the privileges and what are they
Now, I am getting an error while writing like
ERROR 1465 (HY000): Triggers can not be created on system tables
Can we create a trigger on system tables, Is there any work around or it will be supported in higher versions[> 5.1.61] ?
Thanks in advance.
No we can not. Even if we have the best concerned privileges are all and super
See (All) and (Super) Privileges Provided by mySql
After trying all type of privileges like
grant super on *.* to root#localhost
grant all on *.* to root#localhost
I have tried simplest trigger on different tables mysql.db and got same error
Triggers can not be created on system tables // Please accept this
bitter truth
If you found anywhere that triggers can be created on system tables, simply that is wrong
Had you seen this: http://forums.mysql.com/read.php?99,207145 ?
The poster says he needed "SUPER PREVILAGES"
Do you have access to the root user for the database?

Can't alter MySql routine

I am logging in with my main DB user, into Phpmyadmin page/ workbench remote access application and I have permissions issues.
It all started when I tried to alter routines that I have stored in the DB. when trying to alter those routines from the workbench applications nothing just happens.
I can call these routines and execute them, but not alter or get to the scripts.
I searched for hours in distinct forums and get some answers regarding grant access commands
but then I got again permissions issues with error #1142 , command denied to user(main user).
I am really lost here, and already lost hours of work in order to get to the scripts of my routines.
one last note - I have created these routines while I was connected with the same user but from different remote connection (different IP address).
Would really appreciate the help.
here is a solution how I fixed this:
1) Add "mysql" database to the user, you are logged in with
Advice: now you can alter functions and procedures
2) Add the global privilege "SUPER" to your user
Advice: otherwise you will get the following error if you save the procedure/function: "ERROR 1227: Access denied; you need (at least one of) the SUPER privilege(s) for this operation"
CREATE DEFINER = 'admin'#'localhost' PROCEDURE account_count()
SQL SECURITY INVOKER
BEGIN
SELECT 'Number of accounts:', COUNT(*) FROM mysql.user;
END;
See the above example.
You need to login using super user and change the definer parameter in the procedure based on your new username and hostname. The same definer who created can edit the stored procedure.