ACCESS denied error while GRANTing privileges - mysql

I want to allow remote connection from a certain IP.
I have a use coszi_crawl and DB name is same too.
I am logged into server using coszi_crawl user.
I have run this command
GRANT ALL PRIVILEGES ON coszi_crawl.* TO 'coszi_crawl'#'39.32.%' IDENTIFIED BY 'abcqwe' WITH GRANT OPTION;
But this is giving me this error
ERROR 1044 (42000): Access denied for user 'coszi_crawl'#'localhost' to database 'coszi_crawl'
P.S.:
Though I can access coszi_crawl DB from Browser using PHPmyadmin with user coszi_crawl
How can I can solve this problem?

You should use the root account on your database server to update the priviledges, by default the user coszi_crawldoes not have access to granting priviledges on databases.

It means You don't have GRANT OPTION privilege. Login to user having GRANT OPTION privileges, only that user can give grant to other users.
Generally or by default root user has all the privileges so use that user.
Grant privilege

Related

mysql: database specific user permission delegation with grant option and wildcard

I want to have a non-root mysql user that can create another databases and users and grant access to that users to created databases. To do this as root I firstly created a user
CREATE USER asusi_admin#localhost IDENTIFIED BY '123';
Then I grant create user PRIVILEGE to this user
GRANT CREATE USER ON *.* TO 'asusi_admin'#localhost';
Then I grant all privileges to this user for the every database he creates
GRANT ALL PRIVILEGES ON `asusi\_%`.* TO 'asusi_admin'#'localhost WITH GRANT OPTION;
Now I'm flushing privileges
FLUSH PRIVILEGES;
Now I'm logging on to MySQL as newly created user asusi_admin and creating a new database
Now I'm creating a new database
CREATE DATABASE asusi_database;
Now I'm checking that I can use this database
USE asusi_database;
I can use this database, good
Now I'm creating a new user
CREATE USER 'asusi_user'#'localhost' IDENTIFIED '123';
Now I want to grant select privilege to the created user
GRANT select on `asusi_database`.* 'asusi_user'#'localhost'
And here I'm getting an error: 'Access denied for user 'asusi_admin'#'localhost' to database 'asusi_superdb'
Should I relogin as root and explicitly grant access to this database to a asusi_user
GRANT ALL PRIVILEGES ON `asusi_database`.* TO 'asusi_admin'#'localhost WITH GRANT OPTION;
and then relog in as asusi_admin and run the command again
GRANT select on `asusi_database`.* 'asusi_user'#'localhost'
this time it gives me no error and user asusi_user can read database asusi_database. Apparently MySQL wants me to explicitly grant access to the user asusi_admin for the every created database via root account. But I don't want to use the root account. I thought that after executing this command
GRANT ALL PRIVILEGES ON `asusi\_%`.* TO 'asusi_admin'#'localhost WITH GRANT OPTION;
user asusi_admin will be able to grant access to other users to the ecery database that stats with 'asusi_' prefix. May be I missed something or this behavior is designed to be that way?
It seems this is a confirmed bug, that was not fixed yet https://bugs.mysql.com/bug.php?id=75097, so nothing you can do right now with it.

Revoking permissions from user on specific tables?

I have granted all permissions on a database to a user 'demo' with this command:
grant all privileges on wordpress.* to demo#localhost;
Now i want to revoke the user permissions on the table wp_users. I used this command:
revoke all privileges on wordpress.wp_users from demo#localhost;
But i get this error:
ERROR 1147 (42000): There is no such grant defined for user 'demo' on host 'localhost' on table 'wp_users'
Why i am getting this error?
Because, as indicated, you're trying to revoke a grant that doesn't exist.
Making a broad grant makes a broad grant; it doesn't automatically make lots of individual grants that you can then cherry-pick away afterwards.
Simply grant access to the tables you want.

Access denied for user while executing the GRANT command in MySQL workbench

grant select ON . TO 'username'#'%' with GRANT OPTION;
grant select ON . TO 'username'#'IPaddress' with GRANT OPTION;
All the above statements errors out with the Error Code: 1044. Access denied for user 'user'#'IPAddress' to database
FYI I am logged in as a user with all the permissions -- 'GRANT ALL PRIVILEGES ON . '
With the current user I am able to perform all operation , but I want to add more users.
You need to be logged in with a user that has WITH GRANT OPTION as well, such as root#'localhost'. Otherwise, you can do everything else, BUT create new user and issue new grants/permissions.
GRANT OPTION Enable privileges to be granted to or removed from other accounts. Levels: Global, database, table, procedure.
You can read more here are dev.mysql.

How i can give all privilages for a user to all databases in my shared hosting

I have a user and 10 databases in my cpanel and i want grant this user to all databases in my host using sql command.
I used this command :
grant all privileges on *.* to 'myacc_myuser'#localhost identified by 'mypass' with grant option;
But it give me this error :
#1045 - Access denied for user 'myacc'#'localhost'
How i can resolve this problem ?
Thanks.

java.sql.SQLException: Access denied for user

I want to create an user that can access from any hosts to Mysql server
I use
create user abc#10.10.131.17 identified by 'abc123'
and
grant all privileges mydb.* to 'abc'#'%';
But when i run client,the error occurs:
"java.sql.SQLException: Access denied for user 'abc'#'10.10.0.7' (using password: YES)
help me,please!
One obvious guess would be that you didn't do FLUSH PRIVILEGES; after issuing GRANT statement.
Another obvious guess (not sure if typo in the question) is that syntax of GRANT is GRANT ALL PRIVILEGES ON mydb.* TO 'abc'#'%';, with ON in it.
You have created an user with allowing IP 10.10.131.17 and you are trying to connect MySQL Server from IP 10.10.10.7. So it won't work.
To access MySQL Server you have to create user allowing IP 10.10.10.7 or allowing all IPs using %.
CREATE USER `abc`#`10.10.10.7` IDENTIFIED BY 'abc123'
GRANT ALL PRIVILEGES mydb.* TO `abc`#`10.10.10.7`;
OR
CREATE USER `abc`#`%` IDENTIFIED BY 'abc123'
GRANT ALL PRIVILEGES mydb.* TO `abc`#`%`;