How to connect remote mysql database?
I try to connect my mysql database, but get the error:
Can't connect to MySQL server on 'ip address'
After changing the hostname to 'localhost', I successfully connect to the database, why?
Do I need to modify any configuration files? I installed "Centos 7" and "mysql Ver 14.14 Distrib 5.6.51, for Linux (x86_64) using EditLine wrapper"
Thank your help.
1 Reply
MySQL stores permissions based on a literal 'user'@'host' format. If you would like a user to be able to connect from everywhere, you would put the literal wild card in the GRANT command:
GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'%' identified by 'userpass';
You now have separate privileges for:
'user_name'@'ip address'
'user_name'@'oldservername'
'user_name'@'localhost' and
'user_name'@'%'. (and maybe others)
Here are some articles with different ways of looking at grants: