Why do you want to do that? Usually the data explorer is a better way to do that.
By default the database isn’t exposed to a port.
If you really want to expose your database to the world, reinstall with a two container setup (discourse-setup --two-container). If easiest to do it on a new server but topics exist for how to change over.
It’s almost certainly a bad idea. Use data explorer or the API.