Connecting to a mysql running on a Docker container ubuntu 16.04 - mysql

I have mysql container on docker. Mysql is running correcty now(because my application is running).
When I type docker-compose ps I see mysql is up. This is related part in pom.xml :
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://127.0.0.1:3310/fraud_dev</url>
<defaultSchemaName>abc_dev</defaultSchemaName>
<username>abc_dev</username>
<password>abc_dev_123</password>
I am trying to connect mysql on localhost terminal. I am typing this :
mysql -u 'abc_dev'#'localhost:3310' -p
I am typing password. Then I am getting this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I dont know where I am wrong. How can I fix it?
Thanks.

You do not use the standard mysql port 3306. Because of this you have to specify the used port with
mysql -u abc_dev -p -h localhost --port 3310

Related

connect to mysql database server in Windows from Vagrant box

I installed mysql server 5.6, and I can connect to it using mysql workbench, but I'm wondering if I can connect to it from Vagrant box, and I tried the following command, but failed:
vagrant#sdi03:~$ mysql -h 127.0.0.1 --port=3366 -u root -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
Note that I purposely run the mysql server on port 3366 instead of 3306, because I have another mysql server running on Vagrant box on port 3306.
I'm using success connect to ip adress of my windows, it's 192.168.1.55
mysql -u konst -p -h 192.168.1.55
PS I can't connect with root, i create new mysqluser konst with admin's rights

How can i connect to mysql using terminal?

I'm trying to connect to the mysql server on my mac using terminal. I've already got MAMP on my mac but now I have installed XAMPP. when I type this into my terminal
mysql -u root -p
it comes up with this message...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/Applications/MAMP/tmp/mysql/mysql.sock' (2)
I'm wondering is it because of XAMPP? Any suggestions?
have you tried
mysql -h 127.0.0.1 -u root -p
(if the mysql server isn't running on your local box, substitute the IP address of the mysql server for 127.0.0.1)

Can not connect to MySQL Server by 127.0.0.1

I'm using Ubuntu 12.04 32bit AND MySQL Server 5.5.31
I can connect to MySQL Server with following command successfully :
$ mysql -u root -p -h localhost
But when i'm using 127.0.0.1 instead localhost can not connect :
$ mysql -u root -p -h 127.0.0.1
The error is :
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
Any ideas would be awesome.
Maybe the allowed host for root is 'localhost' and your host doesnt map 127.0.0.1<->localhost correctly?
Try setting the host for this user to 127.0.0.1 or % (allow ALL ips to connect)
Have you uncommented the my.cnf's line
skip-networking
Please check this http://dev.mysql.com/doc/refman/5.1/en/can-not-connect-to-server.html for a solution.
Update my.cnf file to include the following line
bind-address=128.2.177.192

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'

Can't get mysqldump to connect to local mysql instance (error 2003 / 10061)

I've got mysql 5.1 on a windows xp machine. It's listening on port 3308. I'm trying to use mysqldump:
> mysqldump -u root -pmypassword dbname > out.sql
Getting an error:
mysqldump: Got error: 2003: Can't connect to MySQL server on 'localhost' (10061) when trying to connect
Not sure what the problem is, looking at --help dumps variables and shows port=3308 as I set in the mysql installation (instead of default 3306). I don't think there's anything different with my installation. I also tried explicitly setting the port # on the command line but still same error.
Thanks
To connect through a port (and not the default 3306), use:
mysqldump -u root -pmypassword -P 3308 dbname > out.sql
Besides that, a simple test to see if MySQL responds at port 3308 is to try telneting:
telnet 127.0.0.1 3308
If MySQL is listening on port 3308, it'll respond with an error and the version running.
Go to run type services.msc
then
locate mysql service and start it .this solved
If your Mysql-Client is 5.5.16 please upgrade it to 5.6.10, this process worked for me if your mysql server is 5.6.10.