I have a Laravel Sail app that was installed without the MySql service, since I want to use the MySql server on the local mac where the application is installed.
How do I do this? Presumably I need to modify the docker-compose file to redirect port 3306, but how? (I tried binding 3306:3306 in docker-compose beneath the line assigning port 80, but it tells me the port is already taken).
As it turns out, the answer is quite simple. Use host.docker.internal as the hostname when inside the container.
Related
Is it possible possible to connect to Fly.io Postgres from a NEXT.js API route served from a Vercel severless function, and if so, how?
I've read and reread the Fly.io Postgres docs, focusing especially on Connecting from outside Fly.io and (since my API routes use Prisma to connect to Postgres) Connecting with Prisma, but it seems I would need to either install flyctl or a set up a WireGuard Tunnel in Vercel, neither of which I could figure out how to do from web searches.
I found essentially the same question on the Fly.io community forum, but unfortunately, no one has answered it after 26 days (as of this writing).
To add a bit more detail, I'm familiar with Heroku Postgres, where a connection string is essentially all that's needed to connect, but it seems connecting to Fly.io Postgres requires a connection string plus a proxy created with flyctl. This was easy to get working on my local machine, but it's not clear how to do this on a remote host like Vercel.
One of the solutions is to allocate an ip address to your app with link here
fly ips allocate-v4 --app <pg-app-name>
Then add these service configurations to the fly.toml file
[[services]]
internal_port = 5432 # Postgres instance
protocol = "tcp"
[[services.ports]]
handlers = ["pg_tls"]
port = 5432
Redeploy your app with fly deploy
Go to your fly dashboard you will be able to see Ip Addresses that you can use as host to connect to the database
I could not connect to mysql with my mysqlworkbench.
I am using mamp and it gives me the below error:
Failed to Connect to MySQL at localhost:8888 with user root
I have put the username "root" and no password.
Hostname:localhost Port:8888
Normally we get this issue when the port is used from another app in the background.
So check your running programs or change mamp port itself to anything else like
port:7001.
I recommend Xampp if you're using Windows Operating system. It works well on port:3306.
I'm running a composition of docker containers of a preexisting project on Ubuntu 20. One container for apache2, one for postresql. I can connect to the webserver through my browser and the webserver container establishes a connection to the postgresql container - so far everything works.
The problem is: I can't establish a connection from my host machine to the postgresql database using php. Whenever I try, I get an password authentication failed for user .. error.
I know that the php code, the username and the password are correct, as all three work when I execute them from within the webserver container.
$db_connection = pg_connect("host=db dbname=MYDB user=MYUSER password=MYPASS");
I configured /etc/hosts on my host to resolve "db" to 127.0.0.1 and also tried using host=localhost. Both didn't help.
Am I getting something wrong about how docker works? I found a couple of OSX solutions which were talking about docker containers running in virtual machines and therefore not being accessible from the host... Which is confusing, as apache2 is reachable from my host.
I did my research on stackoverflow tried solutions from e.g. Connecting to Postgresql in a docker container from outside but they didn't work for me.
I am running postgresql in WSL Ubuntu on windows. Everything is up to speed, my data is loaded and I wish to access the database through some graphical interface. I was thinking pgadmin4.
Is it possible to accomplish this through a windows install of pgadmin4? I installed pgadmin4 on windows and tried to connect the traditional way in the GUI through localhost but am not getting a connection. I figure there may be a special method here.
For everyone else stumbling across this: The best way to do this (that I know of) is to SSH into your local WSL and then configure the SSH in pgAdmin to that.
I have yet to figure out, how to use this remotely.
As long as postgres is running within your wsl2 instance (check with sudo service postgresql status) then within PgAdmin 4 (running in windows), all you need to do is click to "Register" a new server.
Then, while entering the Connection data, set host to localhost and port to 5432 (unless you specified unique port within your postgres instance when creating in wsl2.
See this answer for more detail
There is no special way needed, you should be able to get a connection. Just like your dev http ports are exposed to your browser on Windows, your db port should too.
I had to manually add localhost to pg admin though which is a bit weird.
Make sure your db service is up and running on Ubuntu, sometimes the db service is killed for no reason.
To see if your PostgresSQL service is up or not:
sudo service postgresql status
If it's not, start the service:
sudo service postgresql start
I have created an application in delphi and backend is postgres when i run the application i get the following error
general sql error.could not connect to the server;no
connection could be made because the target machine actively refused
it.[127.0.0.1:1:5433 alias resumep
I uninstalled it and installed it again but it didnt work.Even i changed the port number while installing .
I changed the password and installed again but its giving same error
what is the solution to this problem?
The database cluster of a standard PostgreSQL installation is listening on port 5432. (You can, of course, set up additional db clusters on different ports or configure your database cluster to listen on any other port.)
Any particular reason you try 5433? This is probably the cause of your problem.
If no server is listening on port 5433, the connection is simply not possible.