Sunday, 19 May 2024

Remote MySQL database connection

1. Edit nano /etc/mysql/mysql.conf.d/mysqld.cnf

bind-address = 0.0.0.0

2. Create user and set permission for user remote accesss

mysql -u root -p
CREATE USER 'your_user'@'%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON database_name.* TO 'your_user'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'%';
FLUSH PRIVILEGES;

3. Restart mysql 

sudo systemctl restart mysql

4. Open port mysql 3306 

sudo ufw allow 3306/tcp

Thank you

No comments:

Post a Comment

Golang Advanced Interview Q&A