Use % to allow the user to connect from any IP address.įor example, to grant access to a database dbname to a user named foo with password my_passwd from a client machine with IP 10.8.0.5, you would run: GRANT ALL ON dbname.* TO IDENTIFIED BY 'my_passwd' Configuring Firewall #
In Ubuntu and Debian the file is located at /etc/mysql//mysqld.cnf, while in Red Hat based distributions such as CentOS, the file is located at /etc/my.cnf. The location of the MySQL configuration file differs depending on the distribution. If you have IPv6 configured on your system, then instead of 0.0.0.0, use. If the address is 0.0.0.0, the MySQL server accepts connections on all host IPv4 interfaces. You can set a single IP address and IP ranges. To do so, you need to edit the MySQL configuration file and add or change the value of the bind-address option. Otherwise, if you want to connect to the server over a public network, set the MySQL server to listen on all IP addresses on the machine. If the MySQL server and clients can communicate over a private network, the best option is to set the MySQL server to listen only on the private IP. The first step is to set the MySQL server to listen on a specific IP address or all IP addresses on the machine.
This article goes through the steps necessary to allow remote connections to a MySQL server. , and another is to configure the MySQL server to accept remote connections. One option would be to access the MySQL server through SSH Tunnel For example, you may need to connect to the remote MySQL server from your local system or a multi-server deployment where the application is running on a different machine from the database server. However, in some situations, it is necessary to access the MySQL server from a remote location. By default, the MySQL server listens for connections only from localhost, which means it can be accessed only by applications running on the same host.