MySQL Grant user on specified domain - mysql

I tried to grant user for database at database.com from a domain but it failed. Only the domain's IP works. (example.com is having IP 1.1.1.1)
For example:
GRANT super ON *.* TO 'user'#'1.1.1.1' IDENTIFIED BY 'password';
The above works fine. I can access the database remotely.
GRANT super ON *.* TO 'user'#'example.com' IDENTIFIED BY 'password';
This failed!
When I try to use PHP script to connect from example.com to database.com, it says:
mysql_connect('database.com', 'user', 'password');
Warning: mysql_connect() [function.mysql-connect]: Access denied for
user 'user'#'1.1.1.1' (using password: YES)
Any idea why giving privilege to user base on domain 'user'#'example.com' doesn't work?

As per my understanding your server administrator has restricted to host name, you can check in your server config file (my.cnf) if "skip-name-resolve" is updated.
Even you should call based on IP in your application instead of name but if still you want to do it then comment "skip-name-resolve" in your config file.

Related

Access denied for user "gestioip'#'localhost' (using password: YES)

I get this error installing gestioip. It connects to the DB as root, it creates a db (gestioip db) then it creates an user (the users: gestioip) but this user can't access the DB. (all this via browser on remote machine)
I've tried like similar posts state the following:
GRANT ALL PRIVILEGES ON dbname.* TO 'gestioip'#'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
With no effect giving the error present on the topic.
If I login the in console with:
mysql -u gestioip -p password
it works.
Needless to say that I've followed all the tutorials/installation manuals of the application.
The access to the DB is following:
gestioip#localhost
gestioip#127.0.0.1
gestioip#localhost.localdomain
Also first line in /etc/hosts:
127.0.0.1 localhost
EDIT:
I installed a ubuntu with GUI and I'm doing the install from the LOCAL browser so no remote problems should arise.
Try one of these to grant access to that user on the db u specified.
GRANT ALL PRIVILEGES ON dbname.* TO gestioip#localhost IDENTIFIED BY 'password'
GRANT ALL PRIVILEGES ON dbname.* TO 'gestioip'#'localhost' IDENTIFIED BY 'password'
U can look at this here
Or check in MySQL references guide.
Instead of localhost use 127.0.0.1
In mysql they are not the same. I imagine your connecting on 127.0.0.1 but permissions are for localhost. That is why the command works. Don't mix and match them

Connect to MySQL Database on Local Network

I actually thought I could do this until I tried. I installed MySQL server on one PC in the Local network IP Address (192.168.1.4) and now I am trying to access it from another PC in the same network (192.168.1.5) but I am unable:
C:\Users\DOMICO>mysql -u domico -h 192.168.1.4 -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'domico'#'DOMICO-PC' (using password:
YES)
Surprisingly DOMICO-PC is the PC I am trying to connect from. Why is it not connecting to the given host but trying to connect to Local machine?
You need to give permissions to connect from remotehost
mysql>GRANT ALL PRIVILEGES ON database.* TO 'username'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
You need to have proper permissions to connect. In the computer that has the DB installed, give your user the proper permissions:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'domico'#'DOMICO-PC';
mysql>FLUSH PRIVILEGES;
You can read more here:
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
And here:
https://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html
This is connecting to the intended host as you require it to. t is just stating who is connecting. and where from.
USER#DOMAIN
user : your user running the mysql command
domain : name of the system you are connecting from.
Log into mysql via the server using -u root, ensure the user 'domico' is created and has sufficient access.
creata a new user by mysql server
and give it privileges you can do it by command and by using any server e.g by using workbench
For all users and all host.
mysql -u root -p
GRANT ALL PRIVILEGES
ON *.*
TO '%'#'%'
IDENTIFIED BY 'password'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
QUIT;

Access denied for user 'user'#'host' (using password: YES)

I have a created user in my MySQL database:
CREATE USER 'user'#'host' IDENTIFIED BY 'password';
I have granted that user full privileges:
GRANT ALL ON *.* to 'user'#'host';
Echoing the grant:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'host' IDENTIFIED BY PASSWORD '*03FFC888F82E921D8CA360925A8F443CF326DE89'
I can connect from MySQL workbench using this login credential w/o any issues and execute queries. And it's running on the same machine the web application is running on. MySQL instance is running on another computer in the same local network.
However, when I try to use the same credentials from my web application running in Tomcat7 under Eclipse I receive the error. Please advise.
Note: As of last night, the web application was able to connect just fine. With nothing changing (that I am aware of - I am only one working on this), this morning I could not connect.
RESOLVED:
I added the user with grants using the IP address for the host for the local machine.
I am not sure what changed on the server, but now I am able to connect again.
Would someone possibly be able to explain this change, and with it why I am now required to use the IP address when previously the local host name was sufficient?
Make sure you are using the appropriate hostname, and you're accessing from that host, the user can't connect from another host.
To give permission you must put the password unencrypted.
Example
GRANT ALL PRIVILEGES ON test. * TO 'root' # 'localhost'
IDENTIFIED BY 'goodsecret';
Also must be the same password when you create the user.
Here How adding users to MySQL
Note: For more information on GRANT here is the documentation.
Hope this helps

Unable to connect mysql using ip address

I try to connect my db using host address as my ip address 203.199.209.**,but not able to connect db.if i try to connect my db using host address as localhost it connected successfully.
How to solve this issue?
MySQL grants access based on which host you are connecting from.
Run this command as root:
SELECT user, host FROM mysql.user;
These are the users which exist on your server. Notice the host column.
In short, a user is defined as both a user name (user) and a point of connection (host). When you access your server as localhost, you actually login as some_user#localhost. On the other hand, when you access the sever via its IP address, you actually login as some_user#your.ip.address.here. I guess the latter does not exist on your server.
You may want to create a new user such as some_user#your.ip.address.here or some_user#% (the percent sign is a wildcard; here, it means "any host"):
CREATE USER 'some_user'#'your.ip.address.here' IDENTIFIED BY 'your_password';
GRANT ALL ON your_database.* to 'some_user'#'your.ip.address.here';
If you wish to dig further, see this manual page for more details about MySQL access control, and this page for the CREATE USER syntax.
[edit]
Obviously, as suggested by others, you first need to make sure your server listens to this IP address (203.199.209.**). But if this were not already the case, you should get the following error:
ERROR 2003 (HY000): Can't connect to MySQL server on '203.199.209.**' (111)
The error you are getting definitely indicates a permission issue.
For mysql-5.7.15-winx64 (Windows Version), login as "root" user and run the following queries in MYSQL:
CREATE USER 'user'#'localhost' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON *.* TO 'user'#'localhost' WITH GRANT OPTION;
CREATE USER 'user'#'%' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON *.* TO 'user'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
and then Re-start your MYSQL DB.
For this version of MYSQL DB no changes are required in "my-default.ini" located in the same location as "bin" folder.

mysql db user host

Access denied for user 'root'#'xxxxxxxxxxxxx' (using password: YES)
even though I have an entry in mysql.user table that has host as % and user as root.
I did grant all privileges on . to 'root'#'%';
I would need to see how you are trying to connect to the server to give you additional information. It is possible that the call to the client (or whatever you are using) is munged in some way.