How to create user with remote access in MYSQL ?

I usually need this so I document it here 
Step 1 - Edit my.cnf 
vim /etc/my.cnf
#Chang Bind Address value or add it if its not there 
bind-address = 0.0.0.0
Step 2 - restart mysqld service 
systemctl restart mysqld 
Step 3 - create a user with remote access 
mysql -u root -pyourrootpassword
CREATE USER 'omid'@'localhost' IDENTIFIED BY 'Mypass123@';
CREATE USER 'omid'@'%' IDENTIFIED BY 'Mypass123@';
GRANT ALL ON *.* TO 'omid'@'localhost';
GRANT ALL ON *.* TO 'omid'@'%';
FLUSH PRIVILEGES;

Step 4 - check your firewall if port 3306 is open . 

Comments