Networking – Mysql port forward and access from any pc outside network

MySQLnetworkingport-forwardingrouter

I created a application that use mysql and it will be public. I port forwarded mysql default port on my router and i want that anyone would be able to connect to mysql that is on my computer outside network. (anyone who gets my application ANYONE anywhere). But i dont know how to setup connection for that how do i do that soo anyone can connect to mysql that is on my computer?. This is how the connection string should look like:

"server=my ip;userid=user;password=something;database=databasename"

with default port that is port forwarded. I hope you understand what i want if no i will try to format it and explain better.

Best Answer

The MySQL server likely needs to be told to listen to connections from the outside. Depending on which distribution you use, find or create the right .cnf file (typically /etc/mysql/conf.d/local.cnf or worse /etc/my.cnf) with a [mysqld] block and add the line:

bind-address = 0.0.0.0

Afterwards, restart the MySQL service (typically service mysql restart) and check that lsof -n -i TCP:3306 says the same (as opposed to 127.0.0.1), and obviously check if you can connect to it from the outside.

Related Question