I'm running this on a Ubuntu terminal on my Windows laptop. I'm using docker desktop and have enabled integration with Ubuntu like so:
I've also tried this with docker installed through the Ubuntu terminal (instead of Docker desktop on Windows), but experienced the same issue.
I have a MySQL database in a docker image, and an api docker image, and am running both:
I can access MySQL by running the following command: mysql -uroot -ppassword -h0.0.0.0 -P3306. The api is referencing is connected to this container with the following connection string located in appsettings.json: "Server=0.0.0.0; Port=3306; Uid=root; Pwd=#G3minar31; Database=cybersecuritydatabase". This is also shown in the image below. However, when I try to make a request to the endpoint from the backendapi container (http://127.0.0.1:5001/company/allcompanies), I receive a Can't connect to server error.
How can I resolve this?
UPDATE: When I run mysql -uroot -ppassword -h0.0.0.0 -P3306 in my Windows terminal I receive the following error: ERROR 2003 (HY000): Can't connect to MySQL server on '0.0.0.0:3306' (10049), but if I run mysql -uroot -ppassword -P3306 without specifying the host, MySQL starts successfully.
0.0.0.0 or 127.0.0.1 in config won't work it will point to the app container
either you:
change db address in appsettings.json to your machine local address e.g: 192.168 ..
create a docker network and connect the 2 containers, change db address in appsettings.json to mysql container name instead of an ip address
Run mysql and backendapi with docker-compose, change db address in appsettings.json to mysql service name instead of an ip address, I recommend this
Related
I am successfully able to login to a VM over SSH and to the SQL server from the command line.
But when I try to add a connection on MySQL Workbench and using the same credentials, same host (hostname is an IPV4 address), it says
Failed to Connect to MySQL at <Ip address>:3306 through SSH tunnel at user#VM with user <username>.
Unable to Connect to localhost.
Do anyone have any idea on this issue
I have no mysql installed on my local machine.
Try connecting OVER ssh through commandline and connection was successful. See below
ssh user # <ipaddress of VM>
then
mysql -h <Mysqlhost> -u < user > -p < database > -A
But when I try to do the same via MYSQL workbench, it fails.
Make sure you fill all the details like shown in the image below.
The error message you have posted shows that MySQL Hostname and Username is not filled.
I tried to install a MySQL cluster with the Docker image below.
mysql/mysql-cluster - Docker Image | Docker Hub
The Docker image is pulled and run successfully.
Despite that I could connect to the cluster in the terminal (as shown in the screen capture below), I don't know how to connect to it with MySQL Workbench or DBeaver.
In your docker run command, you can use -p 3306:3306 (or any available port). Then you can use <host>:<port> from Workbench or Dbeaver connection URL.
I assume that you already know how to add new DB connection to MySQL Workbench or DBeaver. The information that you want is the connection URL and the username/password of an authenticated user that you need to use to connect to your MySQL cluster.
For the connection URL: 192.168.0.10 (no port in your example)
You need to have your MySQL Workbench or DBeaver connect to the URL of the MySQL node, which is mysql1 node in your example. As shown in your screen capture, it is 192.168.0.10 without any explicit port. But if you have troubles with the URL, you can run docker ps to check what host and port that your mysql1 is running and exposed at.
For the username/password: root/tpffnrtm1 (the password is the value of MYSQL_ROOT_PASSWORD as shown in your docker run of MySQL node command)
I assume that you just want to connect the DB cluster by any means (root or non-root privileges is totally fine for you).
I have heroku app running using a Jaws Maria db as a add on, I want to access the database using xampp's mysql on windows 7 machine. I got my database url via
heroku config:get JAWSDB_MARIA_URL --app MYAPPNAME
which got me a string like
mysql://username:password#serveraddress:3306/dbname
i'm trying to access this database url via the command from my cmd
E:/xampp/mysql/bin/mysql -u username -h serveraddress.amazonaws.com -P 3306 -D dbname -p
accoring to the thread Access mysql remote database from command line
after providing the password im getting an error
Can't connect to MySQL server on 'serveraddress.amazonaws.com' (10060 "Unknown error")
Whereas if i try to connect to ths database from c9.io I can access it using the command
mysql -u username -h serveraddress.amazonaws.com:3306 -p
Can anyone help me so that I can access it from xampp's mysql in windows as well. Cant figure out what am I missing here
I would like couple things clarified.
(I have mysql client installed on my remote VM running on Ubuntu 16.04, goal is to access the database from within R but I have been trying so far with mysql as such: mysql -u root -p -h fe80::883f:XXXX:XXX:XXXXX -P 3306 where for "XXX" I tried every ip address I get in windows command line when the command ipconfig is issued.
To narrow down my troubleshooting I want couple pointers:
Do I need to give the IP address for my remote(cloud) instance in the mysql config file (thus find my.cnf or its equivalent in windows in dir where mysql server is installed and bind the address for the remote/cloud VM I am trying to access the db on my laptop from).
2 SSL, is this something that needs to be enabled?
Additionally, from Bash on Ubuntu on Windows (WSL) I am able to log into mysql server with `mysql -u root -p'xxx' -h ' i.e. the ip address from windows command line ipconfig output called "Link-local IPv6 Address". After going over several posts and using my imagination(which gets me in trouble with troubleshooting), I feel like in some config file in MySQL server dir is have to "bind the address" for the remote VM (which I access via putty from my laptop), am thinking along the right path?
As for the privileges for the root user in mysql server I believe I have given root every privilege (show below):
enter image description here
If you're going to use the RJDBC package, you have to stick with JDBC. ODBC might be "one letter off", but it's not the same thing.
You need a few things to be in place:
The database on your Windows machine has to be running, visible from the Linux machine, and have a JDBC driver JAR available that will let you connect to it. If you tell me your database is Microsoft Access, you're done. There are no free JDBC drivers for Access.
You have to have the JDBC driver JAR for your database on the Linux machine, in the CLASSPATH that R will use to find it.
You need a JDK installed on the Linux machine. I recommend that you install nothing older than version 8.
Once this is in place it should be easy. I've done it.
I solved my issue and can access MySQL sever on my laptop from remote ression(that I access with putty as follows:
in putty first used 3307 as source, checked the remote radio buttons, set destination to localhost:3306 and at Bash prompt in VM:
mysql -u root -p -h '127.0.0.1' -P 3307
Or from Linux (I use WSL) Bash prompt:
# access the remote VM from Windows Linux subsystem(WSL)
ssh -R 3307:localhost:3306 blsingh#149.165.169.21
## access MySQL server on my laptop from Bash prompt on in WSL
mysql -u root -p -h'127.0.0.1' -P 3307
From here its not difficult to figure out how to access it in R; we have a remote port forward and we use the same parameters in R.
☼
I have a MySQL server installed in a remote Ubuntu VM that i access using a VPN and i have some sql scripts that i want to run on that server, to create new Stored procedures and queries.
The the details of the virtual machine are:
IP: 192.168.58.61
Hostname: les12a.fi.fr
I am using putty and i am writting directly the commands, but i would like to run directly a script that is on my Windows machine.I have tried using Source, and path but this works fine when MySQL is on my machine. What is the correct syntax to do that on remote server?
just do:
shell> mysql -u user -p -h HOSTNAME DBNAME < yourscript.sql
HOSTNAME: put the hostname if could be resolved or the ip of the remote server
enjoy
SSH to your server, and then run:
mysql -u USERNAME -p DATABASE_NAME < scripts.sql
Obviously, your scripts should be stored in scripts.sql, which should be in your working (current) folder.