mysql connect hang(remote connect) - mysql

Hi when I try to connect remote mysql
mysql -u root -p xxxx -h xxxx -P 80
mysql: [Warning] Using a password on the command line interface can be insecure.
then I hang at here
Does anyone knows how to slove this

In your command you are specifyng port 80. By default MySQL works on port 3306.

Related

Connect to different port using MySql Command Line Client

By default I am being connected to port 3309.I need to connect to port 3307.How do I do that?
Use -P parameter, like this:
mysql -h 127.0.0.1 -P 3307 -u user_name -p database_name
Important: if you connecting to localhost - use -h 127.0.0.1, NOT localhost, because MySQL will connect by file socket, not by TCP
From command line, assuming you are on the same host, have you tried :
mysql --user root --password (mypassword) --host=localhost --port=33061
In server name specify custom port when not using default one (you can imply it only when is the standard mysql port 3306)
$servername = "localhost:33061";
you can use -P (uppercase) or --port=portnumber
sample
mysql -u root -P 13306 -p databasename
or
mysql -u root --port=13306 -p databasename
Enter this command changing your details.
after that MySQL requests the password for the connection, then enter the password.
mysql --user=user1 --host=127.16.38.1 --port=25060 -p
especially consider about -p and double Hyphen --
I am giving simple way, one liner which summarizes.
mysql -u root -p --port=3316 // I have MySQL port 3316, instead of default 3306
If the --port=3316 is not provided, then MySQL Cli protocol will try with the default port, without asking.
For any other user
mysql -u anotheruser -p --port=3316

XAMPP and hidden service MYSQL DB cant connect

I am trying to remotely connect to my hidden service MySQL DB
mysql -u root -p -h 127.0.0.1 connected
works fine on local host
I am following this tutorial on reddit:
/r/TOR/comments/222bum/running_mysql_as_a_hidden_service/
I have xampp running on Ubuntu and and tor MySQL listens to port 3306 and Apache on 80
I am trying to connect to my DB remotely with command:
proxychains mysql -u root -p -h http://xxxxxxx.onion DBNAME
Getting this error:
ERROR 2003 (HY000): Can't connect to MySQL server on
'http://xxxxxxxxx.onion' (111)
tried this with socat
socat TCP-LISTEN:3308 SOCKS4A:127.0.0.1:xxxxj.onion:3306,socksport=9050
or
socat TCP-LISTEN:3308 SOCKS4A:localhost:xxxxj.onion:3306,socksport=9050
did not work in tor panel it says but only when i try to proxychains mysql -h 127.0.0.1 -u user -p P 33606
Sep 26 18:43:09.000 [warn] Rejecting SOCKS request for anonymous
connection to private address [scrubbed].
thanks for reply but still cant get it to work
root:/var/lib/tor/hidden_service$ proxychains mysql -u user -h TOR.onion database -p
ProxyChains-3.1 (http://proxychains.sf.net)
Enter password:
|DNS-request| TOR.onion
|S-chain|-<>-127.0.0.1:9050-<><>-4.2.2.2:53-<><>-OK`enter code here`
|DNS-response| TOR.onion is 104.239.213.7
|S-chain|-<>-127.0.0.1:9050-<><>-104.239.213.7:3306-<--timeout
ERROR 2003 (HY000): Can't connect to MySQL server on 'TOR.onion' (111)
GRANT ALL ON Databasename.* TO 'user'#'127.0.0.1
getting some error in console phpmyadmin SQL error
i m prety new to this any help is appreicated
mysql workbench works fine on localhost but when trying to add the onion instead of localhost it dosent work:******
Any suggestions thanks
Change your interface to 0.0.0.0 so external connections can happen (bind-address=0.0.0.0 in my.cnf or equivalent)
GRANT access to the external IP in MySQL: GRANT ALL ON <DB>.* TO '<user>'#'<external_ip>';

Could not log into mysql server

When I login without specifying host name, I could not login
mysql -u root -p
It displays the message
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2)
But if I use hostname, I am able to login
mysql -h 127.0.0.1 -P 3306 -u root -p
It didn't allow, even if I use localhost as my hostname
What is the reason for this?
I would check that mysql is started
service mysqld start

Connecting mysql on 3306 and 3007

I am able to connect to the db instance using 3306 and 3307
mysql -hlocalhost -P 3306 -u root -proot test
mysql -hlocalhost -P 3307 -u root -proot test
This is also working.
But it is actually running only on 3307, tomcat is able to connect to db only on 3307.
What does this mean? Is it an expected output?
Normally mysql listens only to one port (default is 3306, some installations put 3007 into the startup script for whatever reasons).
If you do not have more than one instance running this should not happen.

Connecting to MySQL through Cygwin

I have XAMPP running on my desktop and can connect to the MySQL server via phpMyAdmin. However, when I try to connect through Cygwin:
Error: Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2)
I've tried connecting to MySQL on the same machine, my local dev server and my remote server, all failed.
mysql -h 127.0.0.1 -P <PORT> -u root -p
This is what worked for me. Make sure you check what is the correct port.
Check the mysqld PID with:
ps -sW | grep mysqld
And then find the PORT with:
netstat -nao | grep <PID>
Have fun!
you can also add the alias of itself.
alias mysql = 'mysql -u {user} -p{password} -h 127.0.0.1'