I know this is not a particular php question, but it is to do with accesing php by using mysql when the file is not hosted on the same domain.
For example, im using hyperedit, the php coding tool that allows you to display the results of php in realtime as you code.
However when i try and type my mysql code in, that i know works(i tested it using my servers built in php/html etc creator) i get a error:
Connection refused (trying to connect via tcp://myservername.servername.com
Its definitely not my code, i think instead it is something to do with the fact that the file is not being hosted on the server? I have only tried it in hyperedit but i think the same would occur in other programs too.
I know its not specifically php or coding related, but i thought this is the best place to ask!
If anyone could help me it would be great!
Thanks very much!
This is because your local development machine does not have access to the mysql server in question.
If this is a shared account, you may be able to grant access to your remote machine's IP/hostname through cPanel. If you have direct access to the remote box through the cli, you can do it via a sql GRANT command, like so:
GRANT SELECT ON mydb.* TO myusername#'my_IP' IDENTIFIED BY 'mypassword';
Otherwise, it may be locked down in a shared environment where only machines on the local subnet can access the mysql server (cough, GoDady, cough).
So there's no real answer. Either you have the privileges to give your remote machine access, or you don't. If you don't, consider using another host that does allow you to do what you need.
Related
I have tried everything
Wamp and XAMPP only provide thier own local server and wont let me specify my own server
I have tried IIS and PHP but it doesnt work at all
I would like a simple way to get my SQL server to use PHP in my domain, i dont need it to be remote access yet
Appreciate some hand holding at this point :(
Thanks
Hi thanks for replying
I have explained below what everything meant by using xammp or want iis and php
The server I have is on the Microsoft SQL server management studio
All of the all in one installers will just user local Host and thier own server and database I want to use mine.
Whenever I try using MySQL connection it says it has activley refused connection.
I've added my credentials into the security section on the server. Allowed remote login and specified ports on the server manager program.
Why isn't there a simple step by step program to enable php use on my server and or connect it to my online site..
I have a mysql database at my web hosting service, which I would like to access from a C# application on my local computer.
Due to account restrictions, I can't enable remote connections on the database server.
I would like some suggestions on how to execute CRUD operations on the database remotely i.e. from my localhost or any other place which is not on the server itself. The first idea that popped in to my head was to create a PHP REST API on the server and let it do the database work.
Is that the way to go? If so, is there anything similar created already, or do I need to make it from scratch? Perhaps you have other ideas?
Basically, I want to create an application like this:YOUTUBE
I want to create an application that when I add some information from my web host (either PHP or MYSQL) VB.NET will read it.
From your website you'll need to insert the data into your MySQL database.
The problem with using the database provided by your web host is that the chances are, due to 'Security Reasons' the will have disabled external access.
This means that any files outside of your web server (your sites root/sub directory) will not be able to access the data. So, while your website will be able to connect without a problem, your program will not.
Some hosts give its customers the opportunity to add an IP address to a white list which enables them to bypass their security system. However, most will not give you this option.
My suggestion is that you either rent a VPS where you can run both the WebServer and Your MySQL database (and PHPMyAdmin) from or Set Up A MySQL database on your PC (its not that difficult just read the manual and youll be fine). If you had a VPS then you would no longer need your pre hosted webserver as you could run your own. You would need to point your domain name to your VPS webserver. It will act just like any other.
By running your own MySQL Databse you are given the option to enable remote access. This means that any external entity with the correct details will be able to connect.
If you cant get a VPS or don't want to run your own server or rent a server that allows for external access. Check out db4free.net .They provide you with a free MySQL Database with external access for Developers to test out their systems. They are not ultra fast so that's something you may want to be aware of. Another thing is that your data that's held can be removed at any time. The servers are not there to be used permanently just for testing.
So how do I connect to it through VB???
Good Question! To establish a connection, I suggest you use MySQL.Data library provided my DevMySQL themselves and import it into your program. Done so by Imports MySQL.Data.MySQLClient. This is written by them to work with their databases. Yes you can connect using some of the functions already in VB but in my opinion they don't work as efficiently. You'll need to download the MySQLConnector to connect as well.
Hopefully That Answers Your Questions. Any Problems Just Comment below!
Regards
Joe
I am very new to this server setup and database connectivity. I googled a lot but couldn't find the solution for it.I am developing an android application which needs to post data to remote database. Which is done.
Now i have to setup MySQL Database in the new Windows Server 2008. I have installed and managed to get access the root user(Which is fine). Now i want to access this database from my local computer[Which is iMac]. I already set the privileges by following this link. When i tried to run from my web application it shows the following error.
Error: unable to connect to database. Host 'xx.xx.xxx.x' is not allowed to connect to this MySQL server
Here is my questions
1.) How to get access to the remote MySQL database from any computer?
2.) How to run the web application in the server?Like Web Hosting i.e Do i need to setup ftp account and put the stuff over there?(For Eg: testhost.com/connecttodatabase.php by executing this it will execute whatever code in testhost server. But i have no idea how to do that for my server).
Any help is much appreciated.
Alternately, You can also try...
use the_database_name;
GRANT ALL PRIVILEGES ON
the_database_name.*
TO
'the_user_in_php_code'#'%'
IDENTIFIED BY
'password_of_the_user_in_php_code';
FLUSH PRIVILEGES;
source:
http://forums.devshed.com/mysql-help-4/host-is-not-allowed-to-connect-to-this-mysql-server-366908.html
I'm using XAPP under windows and my website just working well!
when I deployed it on the host server, it seems to be working normally, but the insert requests to MySql doesn't have any effect, nothing is changing on the database!
Does anyone had this issue before? is there any configuration in MySql to make it accept insert requests? or simply whats the best way to make it work!
[EDIT]
I use PhpMyAdmin, I have two tables members and notifications, I wanna configure permissions so I can Insert into the notifications table, any hint please?
thank you
check the permissions on the database server for the username and password that you are using. It can also be restricted by IP address, among others.
Indeed, the administrator can set read-only privileges for a user or for a specific table.
Check out the "grant" command for more information.
it would be helpful if you could find out the error message that MySQL is returning. check your web server log files. if you are using some shared hosting plan, there should be an option in your host control panel to see the web server log files. PHP is configured in most places so that error messages are stored in web server log files. find out what is actually happening there. it could be permissions most likely.