I like to keep the default settings of only letting localhost access the databases for the most part. From a SSH session you can enable access to a particular user from a particular IP in order to use programs like Navicat or enable access from another file server.
- First connect to your server via SSH.
- Then launch mysql by typing the following:
mysql -u admin -p
- Now we will grant access to the desired ip address:
GRANT ALL PRIVILEGES ON *.* TO user@ipaddress IDENTIFIED BY "password"
- Now just reload the server’s privileges:
FLUSH PRIVILEGES;
- You can now connect to your database from your ip address with the user and password specified!
Now, let’s say that you’re feeling adventurous and you want to grant privileges to yourself from any IP address (not advisable). Just use the wildcard statement (”%”) in place of the ip address.
GRANT ALL PRIVILEGES ON *.* TO user@"%" IDENTIFIED BY "password";
For more info on the GRANT syntax.