Skip to content

Instantly share code, notes, and snippets.

@karson
Last active January 16, 2023 15:25
Show Gist options
  • Save karson/2aa7abf9bbf0d920de76b3b71c354fd9 to your computer and use it in GitHub Desktop.
Save karson/2aa7abf9bbf0d920de76b3b71c354fd9 to your computer and use it in GitHub Desktop.
Allow remote access to existing user in Mysql Database
#for new user
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
GRANT ALL ON *.* TO 'myuser'@'localhost';
GRANT ALL ON *.* TO 'myuser'@'%';
FLUSH PRIVILEGES;
#For existing users
#This grants root access with the same password from any machine in *.example.com:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%.example.com'
IDENTIFIED BY 'some_characters'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
#If name resolution is not going to work, you may also grant access by IP or subnet:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%'
IDENTIFIED BY 'some_characters'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment