Mysql remote command using socket file but no password - mysql

I generally connect to to mariadb using this command
sudo -u root <mysql_env> mysql -S /var/mysql/state/mysql.sock
Now I am trying to do remote command to connect another host but its expecting a password which I dont provide at all.Can someone help?
sudo <<mysql_env>> mysql -u root -p -S /var/mysql/state/mysql.sock -h remote_hostname -P8989 dbname -e "select * from t1"
Error received:
ERROR 1045 (28000): Access denied for user 'root'#'remote_host_ip' (using password: **YES**)
if i don't use -p in the string above its giving me a straight error without asking password:
ERROR 1045 (28000): Access denied for user 'root'#'remote_host_ip' (using password: **NO**)

A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing on the same host operating system.
Connecting to a remote endpoint via unix domain socket is not possible therefore. Instead use TPC by specifying hostname without a socket.

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.

Installing SQL problem - "Your connection attempt failed for user 'root' to the MYSQL server at localhost:-3306

I cannot log in through the terminal either:
When I type in terminal: mysql -u root -p -h localhost -p 3306
I see the following message:
"Enter password:
ERROR 1698 (28000): Access denied for user 'root'#'localhost'"
I have tried many solutions proposed throughout the internet, with no avail. I believe, possibly, these are the problems:
I did not create a user with CREATE USER - I merely installed mysql, opened port 3306 through firewall,configured its installation security and created a password.
Maybe my router has my port blocked. I do not know how to check this, but it is very unlikely.

--defaults-group-suffix not working with correct credentials in .my.cnf

I have problems connecting to my DB through --defaults-groups-suffix.
~/.my.cnf
[clientdblive]
user=xxx
password=xxx
database=xxx
host=mysql5.example.com
My bash script where I am connecting from:
mysql --defaults-group-suffix=dblive
Returns an error:
ERROR 1045 (28000): Access denied for user 'xxx'#'localhost' (using password: YES)
It somehow seems to ignore the host option in my config file. When connecting directly through the terminal with
mysql -h mysql5.example.com -u xxx xxx -p
it works fine :(
MySQL version: 5.6.19-67.0-log
The problem was a special character (#) in the password. Putting the password in "quotes" fixed it.

Mysql connect by command line permission denied but workbench works fine

I got mysql host, username, password, port, then I use mysql workbench to connect, it's just fine.
But when I use command line:
mysql -h x.x.x.x -u myusername -P myport -pMYPASSWORD MY_DB_NAME
It reported error:
ERROR 1045 (28000): Access denied for user 'myusername'#'mylocal_ip:55489' (using password: Yes)
First of all, the command line connection seems like auto add my local ip address and a random port to my username, can I make a connection without these tails?
Then why mysql workbench can connect success? Does workbench use different command from my command line command?

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.