How to grant user privileges in google cloud using mysql? - mysql

I have been trying to drop some of my views in my google cloud database
I ran into this error:
ERROR 1227 (42000) at line 74225: Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation
Based on this document: https://www.labnol.org/code/revoke-grant-permissions-mysql
I ran this query SHOW GRANTS FOR root and I got
'GRANT USAGE ON *.* TO `root`#`%`'
'GRANT `cloudsqlsuperuser`#`%` TO `root`#`%`'
I tried to revoke privileges with this command REVOKE ALL PRIVILEGES, GRANT OPTION FROM root but again I ran into another error 'Error Code: 1269. Can't revoke all privileges for one or more of the requested users'
Is there any solution for how can I grant the user privileges in order to drop tables?
Did I miss something in these commands?

Could you please confirm if you altered the users on that instance before?
Also, could you try to do this on a fresh instance, to see if you get the same behavior.
Create a totally new, fresh database instance with v5.7.
Connect to the database as root#%.
Run the Insert/Delete/Drop query and see.

Related

Trying to give access to a database in sql with GRANT ALL PRIVILEGES and it dosen't work

I'm trying to deploy a project in heroku with database, i followed all the steps like install the addon clearDB and all the stuff, the problem its that i cant give the user the privileges it need, im using MySql Shell 8.0.
When i run the code it appear to be ok because it shows Query Ok, 0 rows affected, also i run FLUSH PRIVILEGES and appear the same.
Then i tryed to import the database with Data Import and always appear the error ERROR 1044 (42000): Access denied for user 'blablabla'#'%' to database 'instrumentos'.
Its strange because i followed too the new steps, that they are create a new user and then give it to it the privileges.
CREATE USER 'blablabla'#'%' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON instrumentos.(*) TO 'blablabla'#'%' WITH GRANT OPTION;

How to revoke and grant permissions to a user with GCP's new managed MySQL 8.0

I had no problems making a test MySQL server and applying permissions a week ago with their MySQL 5.7, but trying out the new 8.0 version, I can't seem to alter permissions as easily, if at all. I'm logged in as root remotely, but a local cloud shell instance does the same.
I'm trying to create a new user that only has access to one database, but I can't seem to get past the part where I revoke all default permissions first.
My method:
CREATE USER 'test_user'#'%' IDENTIFIED BY '{password}';
Gives no error. (I've also tried creating a user through GCP's admin panel)
SHOW GRANTS FOR 'test_user'#'%'; returns GRANT USAGE ON *.* TO `test_user`#`%` (I assume this means the new user has full permissions?)
Then, trying to remove all privileges to start fresh with the user,
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'test_user'#'%';
shows:
Error: UNKNOWN_CODE_PLEASE_REPORT: Access denied for AuthId `root`#`%` to database 'mysql'.
I'm pretty new to Mysql, so I'm unsure if this is my fault or just a bug. Thank you!
First, I would like to point out that GRANT USAGE ON *.* TO test_user#% means the inverse, it means that the user has no privileges ! ( more info: Mysql Reference )
Secondly, I think that's what causing the error is the ALL PRIVILEGES keyword, it may have been removed in v8.0, so just go straight after user creation and grant him the privileges that you want on a table/database.

Mysql workbench Error 1044 / 1142: Access / Grant command denied to user ''#'localhost' for

I work on a Mac OSX 10.6.8, and I use Mysql Workbench to learn how to handle databases (I'm a beginner as far as databases go). Now, I have created a few users, and I'm trying to toy around with giving these users' rights, and let them interact with each other by granting and revoking each other various rights.
I have logged in via the root user and supposedly given all "toy users" their initial rights by using the necessary grant queries (verified via queries using "show grants"), but then I try to log in as the various users. Let's say two of these users are named "Sofia" and "Martin", and I want Sofia to give Martin the update- and insert-rights to a table "Book". Sofia was given the necessary privileges from my root-login unless I am mistaken, so I write (when logged in as Sofia)
grant update, insert on Book to Martin;
This yields the error
Error 1142: GRANT command denied to user ''#'localhost' for table
'book'
Further, I try to figure out what rights Sofia does have, and enter the following query
show grants for Sofia;
when logged in as Sofia. The response:
Error 1044: Access denied to user ''#'localhost' for database 'mysql'
What is this mysterious ''#'localhost' user the errors are talking about? What should I do to make things work?
grant update, insert on Book.* to `Martin`#`%`;
please click edit to see the back-ticks
See the MySQL manual page on SHOW GRANTS

#1227 - Access denied; you need (at least one of) the SHOW DATABASES privilege(s) for this operation

I am following the new boston mysql tutorials, and at the very beginning he is writing SHOW DATABASES. In my case I get the following error
"#1227 - Access denied; you need (at least one of) the SHOW DATABASES privilege(s) for this operation".
I am very new to phpmyadmin and I have googled how to grant a permission but I am unlucky
You need to have that privilege granted to the user ie
GRANT SHOW DATABASES ON *.* TO $username_here
The docs for this can be found here
http://dev.mysql.com/doc/refman/5.7/en/grant.html
Someone here also had a similar problem with PHPMYADMIN.
how to add super privileges to mysql database?
Depending on your username you can also use this from the console
GRANT SUPER ON *.* TO user#'localhost' IDENTIFIED BY 'password_asljk8902314';
flush privileges;
Please make sure your username is correct.

Information_Schema broke after moving SQL Database

A few weeks ago I had some problem moving my MySQL database. I copied it from one server to another. Now there is something wrong with the privileges.
I can create users, databases etc when logged in as root, but I can't change users privileges, which is not good as I don't want to give my script route access.
The error I get is ..
GRANT ALL PRIVILEGES ON `newdatabase` . * TO 'newuser'#'localhost' WITH GRANT OPTION ;
MySQL said:
#1044 - Access denied for user 'root'#'%' to database 'newdatabase'
So I did some reading and it appears my information_schema might be bust. The suggestions were to run flush tables on there which I have done via phpmyadmin and mysqladmin but this hasn't helped.
Any ideas?
Thanks
Possible root cause:
GRANT fails, because root#% does not have all privileges on newdatabase.*.
In short, you can only grant privileges you have in the first place.
This has nothing to do with the information schema.
Check which privileges root#% has.