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

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

Related

Access denied for user 'root'#'localhost' when connecting to mysql

I have been researching this for close to 4 hours but still, I can't connect my Invision Community 4 forum to my mysql ran on localhost with xampp.
I can connect from the shell, but I can't connect to it from elsewhere.
Access denied for user 'root'#'localhost'
I think that remote root access is disabled by default. Run this SQL command via the shell:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES;
Most likely you don't have the other "IPs" (like localhost) defined.
Follow these steps to fix it:
Execute this query: SELECT `Host`, `Password` FROM `mysql`.`user` WHERE USER = 'root';
Check results, in this example the pc host has no password:
Host
Password
localhost
*81F5E21E35407D000A6CD4A731AEBFB6AF209E1B
pc
127.0.0.1
*81F5E21E35407D000A6CD4A731AEBFB6AF209E1B
%
*81F5E21E35407D000A6CD4A731AEBFB6AF209E1B
Check how are you connected: SELECT CURRENT_USER();:
CURRENT_USER()
root#localhost
Now you know how you are connected and if all the user/host pairs share the
same password or not, and maybe update the one that you want to change.

Mysql not listing all Databases for root user

I have a mysql database running on k8s cluster inside pod. it was previously listing all the databases when i login through mysql -u root -p and then entering password. But my application was not able to connect to that database and was showing 1045, "Access denied for user 'root'#'ipaddress' (using password: YES)" there was just one host which is % and user was root
i have updated secrets as well and restart deployment but still it was showing the above error.
then i ran this command to grant all privileges to root user
GRANT ALL ON root.* TO 'root'#'localhost' IDENTIFIED BY 'password';
it creates one more host for root which is localhost. Now when i try to login with
mysql -u root -p
it is not listing my databases and just showing
And now host is localhost. what should i do to get my database back.
In MySQL permissions are granted for "accounts" which consist of a user name and a host name [1]. So in terms of GRANTS:
myuser#127.0.0.1
myuser#192.168.1.1
The above are two different users. The wildcard in terms of permissions is %. However % and localhost are mutually exclusive as explained here.
So having that in mind you would need to run something close to:
CREATE USER 'root'#'%' IDENTIFIED BY 'changeme';
GRANT ALL PRIVILEGES ON your_database_name.* TO 'root'#'%';
In order to enable connections coming from a different host. Please keep in mind that using the username root should be avoided. Instead, use a dedicated user for your needs.

Mariadb host works on “localhost” but not IP alternative - 127.0.0.1

I am trying to connect to my database through an ash tunnel using sequel pro but it is not working and forces me to use 127.0.0.1 when entering "localhost" which leads to the problem where if I run on the command line:
mysql --host "localhost"
It works
If I run:
mysql --host "127.0.0.1"
I get the access denied error:
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
What is going on?
I have tried:
update user set host='%' where host='localhost'
but this does not work.
Many SQL servers have two or more different user entries for every user that might come in via either localhost or remote. (127.0.0.1 counts as remote).
For example, for the root user, you might have these three user entries.
CREATE USER 'root'#'localhost' IDENTIFIED BY REDACTED;
CREATE USER 'root'#'127.0.0.1' IDENTIFIED BY REDACTED;
CREATE USER 'root'#'%.example.com' IDENTIFIED BY REDACTED;
There's nothing much special about the name root except that it has been granted a lot of privileges when your MySQL was installed. You need to grant the same privileges to the other versions of root#whatever you create.
I created a new user:
CREATE USER 'non-root'#'localhost' IDENTIFIED BY '123';
and then granted them all the same privileges:
GRANT ALL PRIVILEGES ON * . * TO 'non-root'#'localhost';
and then deleted root and renamed non-root to root
and now it finally works.

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;

Can't access MySQL on LAN server

MySql is installed on a Ubuntu server.
I am running Windows 8.
Logging in through Putty. I can log in to database with both root and webadmin user accounts.
I can also log in through my browser, using <server ip address>/phpmyadmin
My problem is when I try to use command line to log in. I am trying that approach because I am developing a webpage to access the database on that server. It fails to connect, so I thought if command line works, the webpage will also work.
commandline:
mysql -u webadmin -p
or
mysql -u root -p
error 1045 (28000): access denied for user 'webadmin'#'localhost'
(using password: yes)
I added an iptables entry to allow mysql and that didn't work.
Also, the firewall on server is inactive.
You need to grant access to the database. You can read the documentation here: https://dev.mysql.com/doc/refman/5.1/en/grant.html
You can run the following (but be careful as it will leave your DB open)
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
That will allow root to connect from any IP and do any operations to the DB. If that still doesn't work, you might also need to run the following before the 2 lines above
CREATE USER 'root'#'%' IDENTIFIED BY PASSWORD '[your password]';