You are here:

MySQL/Inserting Data to MySQL Server

Advertisement


Question
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 :
"SERVER=localhost;DATABASE=inborn_talent;UID=root;PASSWORD=;"

not working connection string is :
"SERVER=173.192.76.44;DATABASE=inborn;UID=inborn;PASSWORD=inborn;"

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

Answer
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

skip-networking

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

MySQL

All Answers


Answers by Expert:


Ask Experts

Volunteer


stuart gregory

Expertise

PHP html, xhtml, css coding and MySQL

Experience

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 http://www.web-application-development.info are complete database driven websites.

Organizations
I have a large number of websites which I host and maintain, such as. http://www.webreger.com http://www.universalscience.co.uk http://www.modellingelectronics.co.uk

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

©2016 About.com. All rights reserved.