MySQL/Inserting Data to MySQL Server
your ans for my question:
Hello! An answer to your question:
I have to insert the data in mysql server, when I am inserting it in localhost it is working but when I insert it in remote host it is giving an error :
"Unable to connect to any of the specified MySQL hosts."
working connection string is :
not working connection string is :
If the script is on the same server that the database is on it is always localhost to connect to the database. However if you wish to connect from an outside source you are correct in using the ip address.
There are always configuration options required on the server. You have to configure you server to allow remote connections to the mysql database first. As default these are rejected for security.
Now My question is :
But Please tell me How to configure server to allow remote connections to the mysql database. Please tell me step by step as I am new in MySql Server
It is pretty straight forward as long as you have root access. Your hosting company should do this for you. All good hosting companies will if you ask them.
If they will not do this then you will need to edit the mysql file
edit file /etc/mysql/my.cnf
Comment out the line that reads
now to allow remote access you will need to add the following line for each IP address that you want to allow access to the mysql database
bind-address = your ip address
Now restart mysql
You will now have remote access