I don't get how to give a user permissions in MySQL.
I am using MySQL RDS on aws. I am creating a user and need access to the reports database. I created a hash password and ran the below.
SELECT PASSWORD('Test123');
GRANT ALL PRIVILEGES ON reports.* TO 'central'#'localhost'
IDENTIFIED BY PASSWORD '*D1AD25EDF929F55FBFF703358EC527';
mysql -u central -pTest123 -h test.com
ERROR 1045 (28000): Access denied for user 'central'#'112.198.130.xxx' (using password: YES)
Why? What did I do wrong?
You granted permission to 'central'#'localhost' but are attempting to authenticate as 'central'#'112.198.130.xxx'. Either connect from localhost, or grant permission to the appropriate hosts.
Related
How do I grant permissions to users in MySQL?
This is the order in which I tried:
First, connect from EC2 SERVER to MYSQL CLIENT RDS.
After connecting, MYSQL created a user to give you permission.
An error occurs when giving the user permission.
My attempt:
mysql> CREATE USER 'injekim'#'125.128.63.112' IDENTIFIED BY 'k12345678!!';
Query OK, 0 rows affected (0.02 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'injekim'#'125.128.63.112' WITH GRANT OPTION;
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
Also, I found similar error information in stackoverflow, but I couldn't solve it.
MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES)
How can I authorize the user who created it?
It looks like you are not logged into the host machine. To use the root user, you should actually be logged into the machine (ssh or rdp) that is hosting the MySQL server.
Example, let's say I am setting at my Mac but need to give a new user access to a MySQL database that is running on a server with an IP address of 192.168.1.10. Assuming it's a Linux server I would ssh to the server from my Mac's terminal by running:
ssh myuser#192.168.1.10
You can now either:
Log into MySQL as root by running: mysql -u root -p (you will be prompted for the password)
Or,
You could become the root user. In my case, I would run the following:
sudo su. Now that you are the root user, you can log into MySQL by running:
mysql -p
If you need an example in a Windows environment, let me know. It will be the same basic idea, but using RDP instead of ssh. From your local machine, get a session on the actual server running MySQL and then log into MySQL as root from the server.
does anybody know in which table godaddy store the users table ?
I have a database created using database wizard and I have added a user using the mysql database wizard to the database. But I still get the error;
Connection failed: Access denied for user 'user1'#'localhost' (using password: YES)
I tried this:
GRANT ALL PRIVILEGES ON *.* TO 'user1'#'%'; FLUSH PRIVILEGES;
But I keep getting;
1045 - Access denied for user 'cpses_odldzcvpqv'#'localhost' (using password: YES)
It must have something to do with the USER_PRIVILEGES table in information_shema. when I type
SELECT * FROM `USER_PRIVILEGES`
IS_GRANTABLE is set to NO.
On unix based systems, mysql treats localhost and tcp/ip separately. If you wish to give access to localhost, you must also give an explicit permission to localhost along with %.
GRANT ALL PRIVILEGES ON *.* TO 'user1'#'localhost' identified by '<password>';
or you can connect via 127.0.0.1 instead of localhost. That'll work.
mysql -u user1 -p<password> --host 127.0.0.1
I'm running Homestead via Vagrant for a local Laravel install. I logged into Homestead via ssh (vagrant ssh), and connected to MySQL using the host localhost, user homestead, password secret. I was able to connect successfully, and running show databases; tells me there's an information_schema database in there. I thought all was well and I could create a new database for my Laravel project and get going.
Unfortunately, running CREATE DATABASE mynewdb; returned:
ERROR 1044 (42000): Access denied for user 'homestead'#'localhost' to database 'mynewdb'
I tried giving the homestead user some more privileges via:
GRANT ALL PRIVILEGES ON mynewdb.* TO 'homestead'#'localhost' WITH GRANT OPTION;
But get back a similar access denied message:
Access denied for user 'homestead'#'localhost' (using password: YES)
I tried a few other variations of that command, using '%' instead of 'localhost', for instance, but it seems like my homestead user just doesn't have the priviliges needed to administrate this db fully.
I thought I should be able to simple restart the mysql service with the --skip-grant-tables flag, and then login as homestead or root and have full privileges. This also failed to work:
vagrant#homestead:~$ sudo /etc/init.d/mysql stop
[....] Stopping mysql (via systemctl): mysql.servic[.ok
vagrant#homestead:~$ sudo /etc/init.d/mysql start --skip-grant-tables
[....] Starting mysql (via systemctl): mysql.servic[.ok
vagrant#homestead:~$ mysql -h localhost
ERROR 1045 (28000): Access denied for user 'vagrant'#'localhost' (using password: NO)
vagrant#homestead:~$ mysql -h localhost -u homestead
ERROR 1045 (28000): Access denied for user 'homestead'#'localhost' (using password: NO)
vagrant#homestead:~$ mysql -h localhost -u root
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
vagrant#homestead:~$ mysql
ERROR 1045 (28000): Access denied for user 'vagrant'#'localhost' (using password: NO)
After those attempts, I logged in with homestead and secret, just to check and see if anything had changed:
vagrant#homestead:~$ mysql -h localhost -u homestead -p
mysql> create database mynewdb;
ERROR 1044 (42000): Access denied for user 'homestead'#'localhost' to database 'mynewdb'
Finally, I noticed in my homestead.yml file that there was an entry that looked like this:
databases:
- homestead
I modified this entry to:
databases:
- homestead
- mynewdb
And then rebooted the homestead VM:
vagrant halt
vagrant up
And then tried again to create the new datbase with the homestead MySQL user. None of this did anything, access is still completely denied for the homestead user trying to do just about anything.
Suggestions to gain access?
I didn't have the patience to try and solve this, as it clearly was not acting right at all. I finally just destroyed the Homestead VM and all its files after backing up my configuration, and reinstalled the machine. Booted it up, and how the homestead user has full access as it should. Not sure what the heck could have happened to it last time, but the lesson here is: Initializing new VM's is cheap, fighting with the wrong permissions is expensive.
If anyone has an explanation as to how I could have fixed this, I'll accept their answer. Otherwise, reinstalling Homestead seems to be the fastest solution.
To login into MySQL as root user, you can use:
mysql -u root -p
and then enter your MySQL password.
To login as another user, you will have to create that user first and grant him privileges.
Create the user using - change newuser to the username you want and password to your password of choice.
CREATE USER 'newuser'#'localhost' IDENTIFIED BY 'password';
Sadly, at this point newuser has no permissions to do anything with the databases.
Therefore the first stage is to grant the user the privileges to do 'things'.
To grant all privileges (select, create, delete, update, drop, etc) on all databases and tables, run:
GRANT ALL PRIVILEGES ON * . * TO 'newuser'#'localhost';
To grant a specific privilege on a particular database and table, just run:
GRANT [type of privilege] ON [database name].[table name] TO '[username]'#'localhost';
If you ever need to deny or revoke a certain privilege, just run:
REVOKE [type of permission] ON [database name].[table name] FROM '[username]'#'localhost';
I installed MySQL to my Mac (with MAMP installer) and have a problem. When I create a user with "#%" hostname this way:
CREATE USER 'test'#'%' IDENTIFIED BY 'test';
and I try to connect via CLI: mysql -u test -ptest, I get this error:
ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using
password: YES)
But when I change hostname to localhost:
RENAME USER 'test'#'%' TO 'test'#'localhost';
it works.
Any idea how to make MySQL use the wildcard?
Thanks.
As YaK suggests, it is because of anonymous user ''#'localhost' created by MySQL installation. Problem was solved after removal of this user. Thanks a lot YaK!
I am implementing Highavailability in mysql with two nodes.
I created an virtual ip (192.168.1.175).
Now from third system I am trying to connect to mysql using command mysql -h 192.168.1.175 -u root -pserver02 I am getting error ERROR 1045 (28000): Access denied for user 'root'#'192.168.1.44' (using password: YES)
Now i searched for the problem and found that root does not have permission to login from ip 192.168.1.44 and from ip 175 and I will have to grant permission to ip 44 from ip 175.
Now when I login through ip 175( in the same system whose virtual ip is this) and give permission for ip 44 using commandgrant all privileges on . to root#'%' identified by 'server02' I am getting the errorERROR 1045 (28000): Access denied for user 'root'#'192.168.1.175' (using password: YES)
I have to test my fali over mechanism by loging from ip 44 to virtual ip 175.
Now how can i resolve this Accessed denied problem.
Thanks
I think you missed the step where you allow the user to connect.
Try running
ALTER USER 'root'#'%' IDENTIFIED BY 'mypass';
or if that fails
CREATE USER 'root'#'%' IDENTIFIED BY 'mypass';
The crendtials are managed in a bit of a chaotic way in mysql, but it's very, very flexible,