You are here:

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 :


  Dear Sir

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

Dear Sir

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


All Answers

Answers by Expert:

Ask Experts


stuart gregory


PHP html, xhtml, css coding and MySQL


My experiance is all first had as I am web developer and I have, and do build many websites all using php and mysql. This ranges from building a simple search engine to secure php login scripts. Some websites like are complete database driven websites.

I have a large number of websites which I host and maintain, such as.

Web application development. (Open University) BSC Honers Computing and development (Open University)

©2017 All rights reserved.