Accessing Database with python or command line - mysql

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.

Related

Mysql client doesn't connect to external server

I'm trying to connect to external mysql server through linux command line.
Whe I try for example:
mysql -h 102.235.10.77 -u root -p password
it gives the next error:
ERROR 1045 (28000): Access denied for user 'root'#'190.201.179.249' (using password: NO)
Where 190.201.179.249 How you can see isn't the external server IP if not my local IP.
I already check out external connections at MySQL Server and 3306 port too, it Seems it's a local problem as if I can't connect to another IP than localhost.
regards.

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.

mysqldump throwing error in perl script , but running fine outside script

I have a script where i take backups through perl script , which is throwing error as mentioned below
mysqldump: Got error: 1045: Access denied for user 'root'#'localhost'
(using password: YES) when trying to connect
I have the root user with with localhost mentioned as % , as per documentation all the host are allowed .
And interesting point is the mysqldump command is running fine outside script ,i.e in shell prompt
Any ideas ????
Run this command to check if root has permissions to connect from localhost
SELECT user,host
FROM mysql.user
WHERE user = 'root'
If you do not have an entry with localhost in the host column, then root is NOT allowed to connect from localhost. You should allow root to connect from locolhost by issuing a GRANT.

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