Skip to content
Advertisement

MySQL is not accessible from public ip installed on linux

I have debian linux system.I installed MySQL on it.I am not able to access it from public access. I edited /etc/mysql/my.cnf and changed bind-address=127.0.0.1 to my server address and then restarted mysql service. But when I restart mysql service it is showing

Warning: World-writable config file ‘/etc/mysql/my.cnf’ is ignored

How can I solve this ?

Advertisement

Answer

Now it is working fine. Steps I performed

Steps:-

1) SSH into VM instance. 2) Go to /etc/mysql directory using cd /etc/mysql 3) Edit my.cnf file. By default the permissions are u=rw,g=r,o=r so we need to change its permissions to edit using

sudo chmod u=rwx,g=rwx,o=rwx my.cnf

4) Now edit this file using
vi my.cnf

5) Under [mysqld] directive change bind-address to 0.0.0.0 bind-address=YOUR-SERVER-IP

6) Comment out the skip-networking # skip-networking

7) Save my.cnf by pressing Esc and :wq and hit enter

8) Restart the Mysql service using etc/init.d/mysqld restart

9) Login to mysql using mysql -u root -p mysql

10) Grant access to user using GRANT ALL ON . TO @’%’ IDENTIFIED BY ”; where . -> database_name.tables (can provide access to particular database) ‘%’ -> IP_address (provide access to particular ip)

11) You need to open TCP port 3306 using iptables or BSD pf firewall using /sbin/iptables -A INPUT -i eth0 -p tcp –destination-port 3306 -j ACCEPT

12) Add firewall rule on Google VM instance Project Name -> Compute Engine -> Network -> Click on default Network Add firewall Rule like Provide any name and under Allowed protocols and ports -> tcp:3306;

13) Done

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement