A
A
Alexey Dzyuba2018-04-23 21:04:10
MySQL
Alexey Dzyuba, 2018-04-23 21:04:10

How to connect to MySQL database from local machine?

There is a server with phpMyAdmin at 185.65.137.xx/phpmyadmin/. I'm trying to connect to the server from the locale using a typical code:

public function __construct($hostname, $username, $password, $database, $port = '3306') {
    $this->connection = new \mysqli($hostname, $username, $password, $database, $port);
                // ...

And $hostname- this 'localhost'.
I'm on windows with a local Open Server.
The question is the same as in the title: how to connect to remote mysql?
UPD (04/23/18 - 21:09 Moscow time) - localhost is registered there, as I understand it, since the connection is configured this way (it's a server, so it doesn't care. I tried to register 185.65.137.xx, but it displays a connection error)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yan-s, 2018-04-23
@Yan-s

You specify a local address, but you need to specify a remote one.
In this case, the port must be open to the outside, MySQL must be configured for access from the outside.

F
forspamonly2, 2018-04-23
@forspamonly2

it is not necessary to put the subd out on the Internet. this will not lead to good. it's much easier for you to set up an ssh tunnel - forward this one port from the server to your development machine. as a bonus, you don't have to edit the connection config. you will have the same localhost.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question