Skip to content

Instantly share code, notes, and snippets.

@memandip
Created January 10, 2021 18:53
Show Gist options
  • Save memandip/38c51bdc240b00c8a4b88eae48d84f5f to your computer and use it in GitHub Desktop.
Save memandip/38c51bdc240b00c8a4b88eae48d84f5f to your computer and use it in GitHub Desktop.
Allow remote connections to remote mysql server
1. vim /etc/mysql/mysql.conf.d/mysqld.cnf or /etc/mysql/my.cnf
2. Add following code to any one of above file
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
bind-address = 0.0.0.0
// allow from any host
3. CREATE USER 'username'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
// for specific host
4. CREATE USER 'username'@'192.168.1.100' IDENTIFIED WITH mysql_native_password BY 'password';
5. Grant privileges to db
GRANT ALL ON *.* to username@‘192.168.1.100’ IDENTIFIED BY 'password’;
6. Flush privileges;
FLUSH PRIVILEGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment