ERROR 1045 (28000): Access denied for user (using password: YES) - mysql

I am trying to have a simple mysql Database on a server and another database on another server that connects to it.
I have done the following :
Installed mysql-server
Created the database
Created the user with :
CREATE USER admin#'localhost' IDENTIFIED BY 'admin';
Given the privileges to this user with :
GRANT ALL PRIVILEGES ON confWeb.* TO admin#'';
Opened the bind-adress
Now when I launch the command mysql -u admin -p -h <address> from another server, it just tells me again and again :
ERROR 1045 (28000): Access denied for user 'admin'#'X.X.X.X' (using password: YES)
I really have no idea what to do at this point. I think I've tried everything.
I tried putting GRANT OPTION in the end of the GRANT line, I tried allowing a lot of different addresses but nothing worked.

In MySQL, a user is identified by both user and host.
This user:
admin#localhost
is not the same user as
admin#'10.242.167.235'
As one option, you could do this to allow connection:
GRANT USAGE ON *.* TO admin#'10.242.167.235' IDENTIFIED BY 'mysecret' ;
GRANT ALL ON confWeb.* TO admin#'10.242.167.235' ;
For a longer discussion of the MySQL Access Privilege System, including "wildcards", the special meaning of localhost, using IP addresses instead of hostnames, etc.
http://dev.mysql.com/doc/refman/5.7/en/privilege-system.html

I do not really know why, but appareantly, it worked when I used the with grant option and first gave access to the database, and then to its tables.
Here is the list of commands that I entered :
mysql> create user 'admin'#'localhost' identified by 'admin';
mysql> grant all privileges on confWeb to 'admin'#'10.69.101.%' identified by 'admin' with grant option;
mysql> grant all privileges on confWeb.* to 'admin'#'10.69.101.%' identified by 'admin' with grant option;
mysql> flush privileges;
Again, I don't really know why it didn't work before and the answers that I saw look like all the documentation I have seen but it looks my problem was somewhere else.

Use following step:-
CREATE USER 'user name'#'IP or % or localhost' IDENTIFIED BY 'password';
GRANT all privileges ON *.* TO 'user name'#'IP or % or localhost' IDENTIFIED BY 'password' ;
flush privileges;
Here in the place of "IP"; you use remote server ip where you want to connect the server.You can also use "%" for useage databases from any plcae in the world.
Now, in Grant option; In the place of "all privileges" you can given access seperately like as select,alter,update etc.

Related

MySQL "mysql there is no such grant defined for user"

This error happened when I granted all privileges to a new root account I just created.
Steps to produce the problem:
CREATE USER 'root'#'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SHOW GRANTS for 'root'#'localhost';
After "show grants" I got the error "mysql there is no such grant defined for user 'root' on host 'localhost'". There were no errors after executing the first three commands. The new user was created successfully.
How do I solve this problem?
More info:
I'm running MySQL 5.7 on my MacOS laptop(OSX 10.10.5).
There is nothing wrong with your posted code but as guess try with wildcard symbol % like
SHOW GRANTS for 'root'#'%';
(OR)
As an alternative, login with your created user 'root'#'localhost' and just use SHOW GRANTS. See Documentation
I don't think mysql allows you to create another root account. So the create causes an error.
CREATE USER 'root'#'localhost';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'#'localhost'
You should check for the existing root account in the user table and you'll find the wildcard to be '%' which should mean you do not need to create a localhost root user.
select * from user where user = 'root';
Asking to show grants on root localhost should work, and does work for me.
show grants for 'root'#'localhost';
Step-1:
sudo mysql -u root -p
Step-2:
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user name'#'localhost';
Ex.-
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'admin'#'localhost';
Step-3:
FLUSH PRIVILEGES;
I think it will work.

MySQL cannot connect [using password: YES]

My new user cannot connect to MySQL database.
Enter password:
ERROR 1045 (28000): Access denied for user 'newusr'#'localhost' (using password: YES)
But I can connect by using:
mysql -u newusr -pPassword
Yes I Flush the Privileges
After some readings i grant some privileges for test
GRANT ALL PRIVILEGES ON . TO 'newusr'#'localhost' WITH GRANT OPTION;
GRANT USAGE ON . TO 'newusr'#'localhost' IDENTIFIED BY 'Password';
no diferents here.
On the server I have 4 users for web purpose (create at the begining) and they connect correct.
All new users have a problem.
Can someone tell me what happen?
There are No anonymouse users, No test default database. I use mysql_secure_installation but no progress on this time.
Since the last time I create a user i twice upgrade MySQL.
I dont see any diferent betwin new and old user by
SHOW GRANTS FOR username
Just for reference, below are the steps to be followed for creating a new account in MySQL:
a. Create user user with password as password where localhost is the MySQL host:
CREATE USER 'user'#'localhost' IDENTIFIED BY 'password';
b. Grant access to the user on db database and table table.
GRANT ALL PRIVILEGES ON 'db' . 'table' TO 'user'#'localhost';
OR, to grant access to all database or table, use *
GRANT ALL PRIVILEGES ON * . * TO 'user'#'localhost';
c. For changes to be effective, you have to reload all the privileges.
FLUSH PRIVILEGES;

event scheduler won't turn on (mysql)

When I tried this code:
SHOW GRANTS FOR 'secret'#'localhost';
this is the result:
Grants for secret#localhost
GRANT USAGE ON *.* TO 'secret'#'localhost' IDENTIFIED BY PASSWORD 'secretpass'
GRANT ALL PRIVILEGES ON `secret\_dbx`.* TO 'secret'#'localhost'
GRANT ALL PRIVILEGES ON `secret\_db1x`.* TO 'secret'#'localhost'
But when i want to set the event_scheduler on
SET GLOBAL event_scheduler = "ON"
this error show :
#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation
then tried this code :
GRANT SUPER ON *.* TO secret#'localhost' IDENTIFIED BY 'secretpass';
FLUSH PRIVILEGES;
And then the error:
Access denied for user 'secret'#'localhost' (using password: YES)
I know I'm using root , I used the username and password to access the control panel of my domain.
Check this docs. All the permissions are given here.
I think you need to code like:
CREATE USER 'secret_user#localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'secret_user#localhost';
FLUSH PRIVILEGES;
For more information check here.
found the answer ... and sadly I have to work on cron jobs because i shared a hosting ... now I hate re-seller hosting

Access denied for mysql user

I get this error when I try to access my database via the user 'spot'#'localhost' identified by its password.
PermissionsError: (1045, "Access denied for user 'spot'#'localhost' (using password: YES)", None)
I create this user using these two lines:
create user 'spot'#'localhost' identified by 'fakepasswd';
grant all privileges on *.* to 'spot'#'localhost';
When I run this code locally, it works fine. When I run this code on a different machine, I get the aforementioned error.
Yet when I run show grants for 'spot'#'localhost' on both machines, they both give me the same output:
GRANT ALL PRIVILEGES ON *.* TO 'spot'#'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4FRO4CA44C47D54D78478C7E2BD7B7'
How can I debug this access problem?
Yo need to grant privileges not only from localhost, run this querys:
create user 'spot'#'%' identified by 'fakepasswd';
grant all privileges on *.* to 'spot'#'%';
flush privileges;
This allow the user to connect from ANY ip, you can replace the % with the ip of your server.

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`#`%`;