Error 1045 MySQL - mysql

I have a remote database which I connect through a sql management with a user and its password. The database has four tables and a view. To put the permissions I have executed the following command:
mysql> grant all privileges on databasename.* to 'username'#'%' identified by 'password' with grant option;
Then, all it's ok. When I connect to the database, I can see the data from the tables but if I explore the view, for example:
select * from viewname;
I get this error:
Error SQL (1045): Access denied for user 'username'#'%' (using password: YES)
I don't know what is the problem, because the rest of the database is OK.

Once you have given the desired privileges for your user, you will need to run this command within the MySQL command prompt:
Flush the privileges with this MySQL command: FLUSH PRIVILEGES;

Related

Unable to change grant privileges for another user from root user

I'm logged in as root user to an Amazon RDS MySql 5.7 database from MySql workbench.
I've added a user via the following command:
CREATE USER 'my_user'#'%' IDENTIFIED BY 'mypassword';
I'm trying to grant access to the user via this command:
GRANT ALL ON *.* TO 'my_user'#'%'
However, this returns the error:
Error Code: 1045. Access denied for user 'root'#'%' (using password: YES)
I'm not sure if this should work if the user already exists, so based in this post:
https://serverfault.com/questions/115950/how-do-i-change-the-privileges-for-mysql-user-that-is-already-created
I also tried this command:
revoke all privileges on *.* from 'my_user'#'%'
However, I receive the same result. I also had the same problem when I tried creating the user with the GRANT command.
Any help appreciated.
This isn't an answer, but I think the root user might be restricted on RDS. When I did a native install of mysql, the command worked.
None other than RDS user can't have the root user privileges.

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

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.

Connection failed: Access denied for user

I am trying to access database on remote server with normal user (testuser) with no GRANT privileges. When I try to access the database using the above user I get the following error:
Access denied for user 'testuser'#'%' to database 'test_db'
I do not have any database interface to directly grant privileges to this user. I have SSH root access to the server. How do I grant privileges to this user?
Login to mysql command line interface with your root user. Run the below commands to give access
GRANT ALL PRIVILEGES ON *.* TO 'testuser'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

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;

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