简体   繁体   中英

MYSQL connecting from outside network

i am having trouble connecting to mysql from a outside network. If i were to connect it locally, it can be done. Assuming i'm a host, what should i do?

Port forward your router on port 3306. This is the default port for mysql. Make sure you have the same port open on your server. Make sure your ISP (Internet Service Provider) allows traffic on this port. I would suggest using something like MySQL Workbench http://www.mysql.com/products/workbench/ to manage your database if you don't already.

You need to set up port forwarding in your router on port 3306 to your local IP port 3306. You'll need to grant rights to a user to allow access from external IP.

For example:

CREATE DATABASE Test;
GRANT ALL ON Test.* TO remoteUser@'10.11.12.100' IDENTIFIED BY 'PASSWORD123';

Or all tables:

GRANT ALL PRIVILEGES ON *.* to remoteUser@10.11.12.100 IDENTIFIED BY "PASSWORD123";

If that don't work check your MySQL server settings, Example /etc/mysql/my.cnf (Debian)

Settings file:

[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306 - CHECK THAT PORT IS CORRECT
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
language        = /usr/share/mysql/English
bind-address    = 1.1.1.1 CHECK THAT IP IS CORRECT
skip-networking = DELETE OR  # FRONT OF IT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM