Ubuntu MySQL Local Network LAN Connection Configuration

Configure MySQL for Local Network Connections on Ubuntu

How to configure MySQL on Ubuntu to accept connections from the local network (LAN). Log in to mysql with root privileges and grant the user <code>user</code> permission to access from any IP address. Edit mysqld.cnf. Remove bind-address as it's in the way. Restart mysql. Specify the local IP address confirmed with ifconfig or ip...

Shou Arisaka
1 min read
Nov 22, 2025

How to configure MySQL on Ubuntu to accept connections from the local network (LAN).

Replace user with the username you want to enable local network access for.

mysql -u root -p
# CREATE USER 'user'@'%' IDENTIFIED BY 'some_pass'; # Execute if creating a new user
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;

sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.bak
sudo sed -Ei 's/^(bind-address)/# \1/g' /etc/mysql/mysql.conf.d/mysqld.cnf
sudo /etc/init.d/mysql restart
mysql -h 192.168.99.101 -u user -p

What weโ€™re doing

  1. Log in to mysql with root privileges and grant the user user permission to access from any IP address.
  2. Edit mysqld.cnf. Remove bind-address as it's in the way.
  3. Restart mysql
  4. Try connecting by specifying the local IP address confirmed with ifconfig or ip. (If this succeeds, it means you can also access from clients like mysql workbench)

Share this article

Shou Arisaka Nov 22, 2025

๐Ÿ”— Copy Links