Max Stevens
Max Stevens

Reputation: 111

Cannot set up remote access to a MySQL server on Linux

I'm trying to set up my MySQL server on my Debian Linux system for remote access. However, I'm encountering an issue where I can't set the "bind-address" variable. I have attempted to set it using the command mysqladmin --bind-address=0.0.0.0 and it returns mysqladmin: unknown variable 'bind-address=0.0.0.0'.

I have also tried inserting this:

[mysqld] bind-address = 0.0.0.0

into both /etc/mysql/my.cnf as well as /etc/mysql/conf.d/mysql.cnf and restarting the server by running service mysql restart

I would run lsof -Pni :3306 to see if it took the bind-address from the config file and was listening outside of its local IP and it would return

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 28978 mysql 20u IPv4 148539 0t0 TCP 127.0.0.1:3306 (LISTEN)

Which indicated to me that it was still only listening locally. I have checked the /etc/default/mysql file to make sure that there weren't any startup options set that were stopping me from being able to access it remotely.

I have tried with the protocol option set to both "TCP" and "SOCKET" but neither work.

How can I get MySQL to listen outside of its local network? Thanks in advance.

Upvotes: 0

Views: 3551

Answers (2)

Ubuntu
Ubuntu

Reputation: 1

sudo apt install mariadb-client-core-10.1

sudo vi /etc/mysql/my.cnf

Add the following to the file:

[mysqld]
bind-address = 0.0.0.0

Save the file and exit.

mysql -u admin -p -P3307 -h 192.168.2.110

Upvotes: 0

0xTang
0xTang

Reputation: 886

  1. check mysql version

    mysql --version

Default value of bind-address shows below:

  • Default Value (>= 5.6.6) *
  • Default Value (<= 5.6.5) 0.0.0.0

So actually don't need set bind-address for above mysql version.

  1. check mysql config file location

    $ which mysqld /usr/local/mysql/bin/mysqld $ /usr/local/mysql/bin/mysqld --verbose --help | grep -A 1 "Default options" Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

check is there any bind-address config in above config files.

  1. restart mysqld service

    service mysqld restart

  2. confirm mysql user created with user@'%' to allow user connect mysql outside.

Upvotes: 1

Related Questions