1

I've managed to allow remote access to our Mysql DB. This is my conf file /etc/my.conf

cat /etc/my.cnf

[mysqld]
local-infile=0
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
bind-address = IP_OF_SERVER
#skip-networking

Issue is, I am able to connect remotely to DB, but if I enable conf file like this, internal application which differs from mine that is using mysql is unable to connect to localhost.

I am not sure how to properly solve this. Are there any additional steps that needs to be done?

I've checked this post, https://stackoverflow.com/a/13811362/5000868 but it isn't clear to me.

This is how my user table looks like (I didn't included password field on purpose)

-----------------------+----------------+-------------------------------------------+-------------
| Host                  | User           | Password                                  | Select_priv 
+-----------------------+----------------+-------------------------------------------+-------------
| localhost             | root           | *                        | Y           
| localhost.localdomain | root           | *                        | Y           
| 127.0.0.1             | root           | *                        | Y           
| localhost             |                | *                        | N           
| localhost.localdomain |                | *                        | N           
| localhost             | 9r9v17559f9tew | *                        | Y                   
| %                     | 9r9v17559f9tew | * 

So to summary, I want to be able to access MySQL with username 9r9v17559f9tew both remotely & localy.

Thanks! EDIT

I've added one more user 9r9v17559f9tew with hostname 127.0.0.1. Further, when I try to access DB localy on the server like this I get the following error:

mysql -u 9r9v17559f9tew -p

Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

And if I try to connect localy or remote like this, I am able to connect:

# mysql -u 9r9v17559f9tew -p -h IP_OF_SERVER
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Community
  • 1
  • 1
fugitive
  • 357
  • 2
  • 8
  • 26
  • 1
    http://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq especially at the end of the answer. I believe you need to be sure to have your mysqld open for both tcp/ip and socket connections ! – Proger_Cbsk Sep 26 '16 at 14:48
  • Yes, I have port open. I've open it via iptables, netstat -tln | grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN – fugitive Sep 26 '16 at 15:05

1 Answers1

1

Just remove the bind-address declarative.

Then restart the service.

From what I can tell, by default MySQL will bind to 0.0.0.0. This allows local and remote access. By specifying the IP of your server, it will only accept connections coming from the eth interface that IP is allocated to.

Thomas
  • 1,401
  • 8
  • 12
  • I've tried that as well, but internal app (SolusVM) is unable to connect to database still. I've tried to bind it to 0.0.0.0 as well, but it didn't helped as well. – fugitive Sep 26 '16 at 14:20
  • Whats the results of? netstat -tln | grep 3306 – Thomas Sep 26 '16 at 14:27