Problems connecting to remote MySQL database - mysql

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

Related

Accessing Database with python or command line

I am able to access and query the database on the web interface of PhPMyAdmin using a user credentials. However, when I am trying the following command line commands:
mysql -h (<url of phpmyadmin>) -u (<non-root username>) -p (<database>)
Or this error:
ERROR 2059 (HY000): Plugin http could not be loaded:
dlopen(/opt/homebrew/Cellar/mariadb/10.8.3_1/lib/plugin/http.so,
0x0002): tried:
'/opt/homebrew/Cellar/mariadb/10.8.3_1/lib/plugin/http.so' (no such
file)
I have also tried replacing host with "localhost" and I get this issue:
ERROR 1045 (28000): Access denied for user 'data_analyst'#'localhost'
(using password: YES)
I am not sure how I can connect to get data from the database even though when I connect directly to the webpage I get access to it but when I try the same on command line I am unable to.
With mysql -h it takes a hostname as an argument, not a url. As using localhost as the hostname generates access denied, its making a connection so -h isn't needed as an option (localhost is the default`).
There needs to be a space between -p and the database name. Check the non-root user authentication password.

Unable to connect to mysql remotely

I have a mysql database running on a VPS. I can ssh into the host and connect to mysql with no problems. I cannot connect to mysql remotely from my desktop. I have performed the following:
opened port 3306 on the firewall
added my local IP to the remote IPs accepted by mysql. This was done via CPanel
executed
GRANT ALL ON dbname.* TO username#'x.x.x.x' IDENTIFIED BY 'PASSWORD'
to tell mysql to let me connect from the specified address.
I execute the following from the command line on my desktop:
mysql -h x.x.x.x -u username -p
I get a password prompt which indicates I am past the firewall and mysql is responding. When I supply the password, it denies access:
ERROR 1045 (28000): Access denied for user 'username'#'x.x.x.x' (using password: YES)
Have I missed something?
The answer was given in the comments, so I will repeat it here to properly close the thread. alvits suspected that the remote user had not been created. It had been created but his comment prompted me to clean up the user table.
I deleted all remote users including loads that had been created by CPanel or migrated from another host. I then started from scratch doing create user and grant all and it works now.
Thanks!

MySQL console: change user host in conncetion string

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.

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.

error trying to connect to mysql server using command line on windows machine

can anyone point out where is the mistake in the command.
mysql-> connect -h 192.168.1.4 -u xxxxx-p error:ERROR 1045 (28000): Access denied for user 'ODBC'#'fis-lap-106.fs.local' (using
password: NO)
It looks like you intended to use a password, but you didn't put a space before the -p
The error is defined here.
User is not allowed to connect from the actual host. Note that MySQL by default only allows connection from 'localhost'. To specify from where a user may connect SQL wildcards (% and _) can be used. Simply 'someuser#%' means that user 'someuser' may connect from everywhere.