[mysqld] user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp language = /usr/share/mysql/English bind-address = 192.168.2.2 # skip-networkingThen restart MySQL and a listener should be running on the system. You can connect using the mysql command, with the -u option to define a user (root) and then the -h to define an IP (in this case 192.168.2.2):
mysql -u root –h 192.168.2.2 –pYou can also use the telnet command to attempt a connection into a given port, which in the MySQL case would be 3306:
telnet 192.168.2.2 3306Now, just because you can connect remotely doesnt necessarily mean that another computer can actually get into any databases. Next, we’ll GRANT access to ALL resources for a user called krypted for all tables on a new database, coming from an IP of 192.168.2.3:
GRANT ALL ON *.* TO krypted@'192.168.2.3' IDENTIFIED BY 'mysupersecretpassword';Or for an existing database called mydatabase, using the same IP and account as before:
UPDATE DB set Host='192.168.2.3' where Db='mydatabase'; UPDATE USER set Host='192.168.2.3' where user='krypted';You’ll also need to open up port 3306 coming in, whether that’s using a firewall or opening traffic in from the internets. Once that’s done, you should be able to connect and use the database as needed.
krypted February 25th, 2016
Posted In: SQL