However, in some situations, it is necessary to access the MySQL server from a remote location. 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. One option would be to access the MySQL server through SSH Tunnel , and another is to configure the MySQL server to accept remote connections. Show This article goes through the steps necessary to allow remote connections to a MySQL server. The same instructions apply for MariaDB. Configuring MySQL ServerThe first step is to set the MySQL server to listen on a specific IP address or 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. 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. To do so, you need to edit the MySQL configuration file and add or change the value of the 7 option. You can set a single IP address and IP ranges. If the address is 8, the MySQL server accepts connections on all host IPv4 interfaces. If you have IPv6 configured on your system, then instead of 8, use 0.The location of the MySQL configuration file differs depending on the distribution. In Ubuntu and Debian the file is located at 1, while in Red Hat based distributions such as CentOS, the file is located at 2.Open the file with your text editor :
Search for a line that begins with 7 and set its value to the IP address on which a MySQL server should listen.By default, the value is set to 4 (listens only in localhost).In this example, we’ll set the MySQL server to listen on all IPv4 interfaces by changing the value to 8mysqld.cnf
If there is a line containing 6, delete it or comment it out by adding 7 at the beginning of the line.In MySQL 8.0 and higher, the 7 directive may not be present. In this case, add it under the 9 section.Once done, restart the MySQL service for changes to take effect. Only root or users with sudo privileges can restart services. To restart the MySQL service on Debian or Ubuntu, type:
On RedHat based distributions like CentOS to restart the service run:
Granting Access to a User from a Remote MachineThe next step is to allow access to the database to the remote user. Log in to the MySQL server as the root user by typing:
If you are using the old, native MySQL authentication plugin to log in as root, run the command below and enter the password when prompted:
From inside the MySQL shell, use the 0 statement to grant access to the remote user.
Where:
For example, to grant access to a database 6 to a user named 7 with password 8 from a client machine with IP 9, you would run:
Configuring FirewallThe last step is to configure your firewall to allow traffic on port 0 (MySQL default port) from the remote machines.IptablesIf you are using iptables as your firewall, the command below will allow access from any IP address on the Internet to the MySQL port. This is very insecure.
Allow access from a specific IP address:
UFWUFW is the default firewall tool in Ubuntu. To allow access from any IP address on the Internet (very insecure), run: 0Allow access from a specific IP address: 1FirewallDFirewallD is the default firewall management tool in CentOS. To allow access from any IP address on the Internet (very insecure) type: 2To allow access from a specific IP address on a specific port, you can either create a new FirewallD zone or use a rich rule. Well create a new zone named 1: 3Verifying the ChangesTo verify that the remote user can connect to the MySQL server, run the following command: 4Where 2 is the name of the user you granted access to, and 3 is the IP address of the host where the MySQL server runs.If everything is setup up correctly, you will be able to login to the remote MySQL server. If you get an error like below, then either port 3306 is not open , or the MySQL server is not listening on the IP address . 5The error below is indicating that the user you are trying to log in with doesn’t have permission to access the remote MySQL server. 6ConclusionMySQL, the most popular open-source database server by default, listens for incoming connections only on localhost. MySQL masuk ke dalam jenis apa?MySQL juga termasuk ke dalam RDBMS atau Relational Database Management System, dimana di dalam struktur databasenya sehingga ketika proses pengambilan data menggunakan metode relational database. Yang juga menjadi penghubung antara perangkat lunak dan database server.
Bagaimana cara masuk ke MySQL?MySQL Membuat Database dan Table. Buka command prompt dengan cara tekan ctrl + R keudian ketik cmd lalu enter.. Buka MySQL dengan cara mengetikan cd AppServ\MySQL\bin\MySQL.. Bila meminta password, masukkan password yang kalian buat (tapi biasanya password defaultnya “root”). Bagaimanakah cara melakukan remote user pada server MySQL?Cara Remote Database MySQL di cPanel dengan Langkah Mudah. 1. Login ke cPanel. ... . 2. Buka Fitur Remote MySQL. ... . Masukkan IP Address. ... . 4. Download dan Install Aplikasi Remote MySQL Navicat. ... . Hubungkan Navicat dengan Database MySQL. ... . 6. Lakukan Uji Coba Koneksi. ... . 7. Mengatur Tabel pada Database. ... . 8. Cara Menghapus Akses Remote Database.. Apakah MySQL itu server?Jadi, MySQL adalah database server yang gratis dengan lisensi GNU General Public License (GPL) sehingga dapat Anda pakai untuk keperluan pribadi atau komersil tanpa harus membayar lisensi yang ada. Seperti yang sudah disinggung di atas, MySQL masuk ke dalam jenis RDBMS (Relational Database Management System).
|