MySQL console: change user host in conncetion string - mysql

I'm trying to connect to the MySQL database using MySQL console.
MySQL has user: test#% without password.
When i'm trying to connect:
mysql -u test -h 127.0.0.1
I got error:
ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using password: NO)
How i can change user 'test'#'localhost' to 'test#%'?

MySQL has a bit strange logic about the placeholder host, i.e. permissions for the host %. (I'm not sure if "placeholder host" is the correct official name for this.) Namely, the placeholder host does not capture localhost. This can be a bit counter-intuitive.
To be able to log in you will therefore either have to connect from a remote IP (i.e. another computer) or have to grant permissions to test#localhost.

Related

Cannot connect to mysql datavbase ERROR Access denied for user... (using password: YES)

Running a php script or trying to connect via terminal (locally) I get the same error
Access denied for user... (using password: YES)
mysql -u username -p'password' -h ip db_name
It passes to the server but get's blocked because of password although correct value was provided.
I've tried several fixes associated to this scenario but to no avail.
When a tried to execute some queries which could provide extra info for the fix, I get
1142 - SELECT command denied to user ... for table 'user'
I've assigned username, password and all privileges in cPanel MySql databases section (for the database) but am unable to connect using the created user as if a root user is blocking access to the database.
Am on GoDaddy host.
These are the only actions that I can preform on my database

I can't connect to MySQL server in any way (on Windows)

My problem is below:
C:\Users\ordek> mysql
ERROR 1045 (28000): Access denied for user 'ODBC'#'localhost' (using
password: NO)
C:\Users\ordek>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: NO)
C:\Users\ordek>mysql -u root -p
Enter password: ****
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: YES)
I tried lots of solutions before asking here. I've even tried reinstalling MySQL but surprisingly this problem still exists. In Workbench I can't connect to any connection. I always login to the MySQL server as superuser and subsequent attempts to change privileges didn't work because I can't log into MySQL in the usual ways.
In Workbench it doesn't matter which user: root or not, you'll get this message.
[Window Title]
MySQL Workbench
[Main Instruction]
Cannot Connect to Database Server
[Content]
Your connection attempt failed for user 'user1' to the MySQL server at
127.0.0.1:3306:
Access denied for user 'user1'#'localhost' (using password: YES)
Please:
1 Check that MySQL is running on address 127.0.0.1
2 Check that MySQL is reachable on port 3306 (note: 3306 is the default,
but this can be changed)
3 Check the user user1 has rights to connect to 127.0.0.1 from your
address (MySQL rights define what clients can connect to the server and
from which machines)
4 Make sure you are both providing a password if needed and using the
correct password for 127.0.0.1 connecting from the host address you're
connecting from
In "test connection"(WORKBENCH) I always get this message:
[Window Title]
MySQL Workbench
[Main Instruction]
Failed to Connect to MySQL at 127.0.0.1:3306 with user user1
[Content]
Access denied for user 'user1'#'localhost' (using password: YES)
In my mind this is a problem with privileges, but I don't know what to do because I'm a beginner at MySQL. If you know how to overcome this problem, please let me know.
I believe you installed MySQL (windows) using .msi package. As it .msi allows you to do the installation step by step and you can set "root" password.
If you have root password, make sure MySQL services are started.
Control panel > services > Mysql
The user ordek seems unknown to mysql . Switch to root user and it will work .
If this is not possible , or the root password is unknown , re-install mysql , make a note of the root password for future use , create the ordek user and assign it the access rights it needs .

Why is mysql (all the sudden) translating 127.0.0.1 to localhost internally?

I have a strange issue with mysql. I want to connect to the database using the mysql client, and since I want to force connection via TCP I do this:
$ mysql --protocol=TCP -uroot -p -h127.0.0.1
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
As you can see, the connection fails, because there is no root access defined for 'root'#'localhost'. This is true - I did not GRANT any privileges to this hostname. However I did specify the root account with full privileges for 'root'#'127.0.0.1'.
I was able to connect to the database in the past with the above mentioned command. However, now it fails. I am not sure if a system update happened in between but something must have changed.
Does anyone have a solution? I would rather not stop the database server for that if possible.
Some more background info. This is running the mysql flavor percona server 5.6 on an ubuntu 14.04 LTE box with everything up to date.

mysql is not reading the .mylogin.cfg file correctly

I have created the .mylogin.cfg file with below commands and then tried to connect to mysql with the --login-path option but unable to connect to it. any suggestion are really useful.
mysql_config_editor set --login-path=test --host=10.219.39.121 --user=vidya --password
mysql_config_editor print --all
[test]
user = vidya
password = *****
host = 10.219.39.121
while connecting it is showing error on different IP address as shown below
mysql --login-path=test
ERROR 1045 (28000): Access denied for user 'vidya'#'10.219.39.122' (using password: YES)
Here my concern is why it is showing different IP address and why it is not able to connect even the password is correct. I am using mysql 5.6.6-m9-alpha60.1-log Percona Server.

Problems connecting to remote MySQL database

When I try to connect to a remote mysql database I receive an error saying I was unable to log into my router's mysql database.
tom#main:~$ mysql -u appleton -p -h 85.17.xxx.xx
Enter password:
ERROR 1045 (28000): Access denied for user 'appleton'#'85.210.169.xxx' (using password: NO)
Even though I am specifying my IP (85.17.xxx.xx) in the argv the error message is showing my Router's external IP (85.210.169.xxx)
I discovered this whilst using DBI->connect in perl.
Am I missing something obvious?
'appleton'#'85.210.169.xxx' is supposed to show your host, not the database's host. It's your full identifier (username#host) for mysql to determine if you are allowed to connect. Do you have sufficient rights to connect to the database from your IP? Access can be granted to users so that they can only connect from localhost for example.
MySQL Docs on Users