I know how to connect to a MySQL DB on a remote server. What I want to do is, connect to the remote mysql server on the clients site without them being able to see my connection credentials by simply downloading the sqlconnect.php file.
the reason for this is because I have built multiple sites that are almost identical. they are essentially re-seller sites. I built it in a way that one database handles all the sites and simple "site ID's" passed on by each site determine the content delivered.
I need to connect to Mysql remotely but dont want to leave the connection file on each persons server. I'm not so much interested in protecting the rest of the code, just the mysql connection credentials itself.
Related
I have two websites (managed separately with Cpanel). I want to use a database on one host from another.
Domains and their mysql ports are: abc.com:2082 and xyz.com:2082.
I would like to use the database on abc.com from a Php script running on xyz.com. However when I try to connect to the database, the connection is showing an error: "Error".
Well, You can do it in two ways first connecting database using database credential. in that case, you need to enable mysql remote permission . if provide % then anyone from any ip address can connect with your database.
Secondly, You can use restful api to exchange data in between. to know more about restful api search in the stackoverflow.
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?
I have set up a website with basic HTML/CSS files and would like to take that one step further and implement a database with some PHP to perform simple queries and whatnot.
My problem arose when I noticed while setting up the database and creating the PHP files that connect to the database (on my local machine), I used 'localhost' as an argument for mysql_connect. When I then went to drag and drop my newly created HTML/PHP files along with my database into FileZilla to upload the pages onto my remote server, there was a problem connecting to the database. I have a feeling that it is unhappy with the whole 'localhost' notion - yet I don't know what to change it to.
Currently, I am using this line of PHP code to connect to my remote database (which is all located in FileZilla-land).
$link = mysql_connect('localhost','Tommy','pass')
Also, as another quick question: does my remote server have its own phpMyAdmin page? And if so... how would one go about finding it? =D
I appreciate anyone who is able to assist me in my endeavors.
Thank you!!
Log on to your database server, check the details and obtain the correct server information such as server, username and password.
Once you change the server details you shoudl be ready to rock n roll. Edit post with the host name/server name and we may be able to find it for you.
You'll have a phpMyAdmin page where you're hosting the site. Check the membership area or cPanel.
You are right in that 'localhost' in mysql_connect needs to be different. 'localhost' is a textual representation of a loopback address AFAIK - it connects to the computer it is hosted on. As you have uploaded it to your server (a different computer) it is now trying to connect to a mysql server on the server host, instead of your home computer (which holds all the data).
To make this work you'd need to get your database onto the server you are now working from, OR depending on your home setup, point it to your local database.
Whether your host has MySQL/PHPMyAdmin available to you is another matter altogether. If they have MySQL it is probable but not definite that they have a phpmyadmin interface.
Contacting the server host will yield more information. If they have MySQL, it is probably as simple as getting the required details from them, and 'backing up' your SQL on your local server and uploading it to the new server (easily done with PHPMyAdmin)
TL;DR: The database you are trying to connect to doesn't exist on the server you're connecting from.
I have two websites with different domains and I have to share data between the two, such as user registered on first website will be login on the second website too.
Is it possible to connect the second website to the first website's MySQL database? I.e. I have two websites www.example1.com and www.example2.com. Is it possible for example2.com to connect to database of example1.com?
I use the following PHP code which works fine for example1.com but not on example2.com:
$conn =mysql_connect("HOST","USERNAME","PASS") or die("cannot connect with db").mysql_error();
$dbname=mysql_select_db("DATABASE_NAME") or die("Error selecting db").mysql_error();
On example2.com, the connection fails with error message
cannot connect with db....
Could you please explain me what is the configuration required for such type of connection and what are the things which may stop this connection?
if the 2 domains are hosted in the same server then no problem at it all you may connect with the database with as much scripts as you want .
if they are in different servers from your database server you can do this but you have allow remote connection for each script IP
It depends on where you host your database and your website. Some webhostings allow only local database connection. So make sure that either both websites are on the same server or that your settings allow you to connect from your PHP code to the remote database and the database allows remote connection.
If you have command-line access to your webserver, check that you can connect using mysql command - see this answer.
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