Remotely managing a mysql database as a limited user - php

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?

Related

How to access Data from another Server not in the same Network

Hello guys.
In our actual project we got a Microsoft Server accessed via remotehost. On this server we installed xampp ,Microsoft SQL Server and our previously in ObjectPascal developed program.
Then we have a Microsoft SQL Server at our Customers. Then we have our Application, programmed in ObjectPascal, installed, that works with the SQL-Server and is programmed by our company.
Our Web-solution is programmed that it can work with the database like our old programm. Furthermore we would like to use the old program for working locally and our web solution for working remotely. Furthermore the databases on the web-server and at our customer are identical.
Now we have the problem how we can access the data at our Customers SQL Server, without the need of complex configuration at our customers network.
Our thoughts were:
A Web Server at our customer and access the data per AJAX.
Customers Server permanently asking the web-server if it needs data
Doing something similar like 'push up notification' sending from the web-server to our customer.
Maybe synchronising to and from the server?
We are able to get the public IP-Adress from our customer and are able to update it if it change, so that is no problem. The only problem we have is, how we can access the data from our customer. Maybe our solutions go to a completely wrong direction, that's why i am asking you guys.
If you could give me some hints, tips and tricks, maybe a link or a technology name would help me and we would be really gratefull for that.
I thank you for your time reading this!

Connecting to OpenShift via Device

Good afternoon all;
I am developing an application for a project that utilizes an OpenShift MySQL Database. At the moment, I have written php scripts that ping the database on our host website, which, is also hosted on OpenShift.
My fear is that anyone can call this php address and either a) DDoS my DB/website, or b) can access or get any data inside said DB. There is nothing highly critical on this database, such as passwords and all, but it's best using best practices.
To my question: Is there a way to directly connect to this DB via various platforms such as iOS, Android, and Desktop (Mac, PC, Linux) and not use php scripts? I am somewhat familiar with OpenShift's PortForwarding, but I believe this is not what I am looking for.
If it is not possible to connect to said DB in this way, is there a way to make this process of getting data from the DB more secure?
Note on my php scripts:
They connect to the DB using a username and password. This user has only select and edit privileges. The purpose is to get fields of data: Building and Amount, and at times changes Amount, based on arguments of the php address. The returned data is encoded using JSON.
Check for NodePort feature in openshift/k8s, that should allow connections if this is a self hosted openshift

Using my php scripts in Android to access database

I need some major help in setting up my android app to add/receive data to/from my database. I'm using Amazon's RDS service in connection with xampp's phpMyAdmin. I've already successfully connected my DB instance to the database in phpMyAdmin. Also, I've written my php scripts to do basic CRUD (Create, Read, Update, Delete) commands in SQL. I've been following this tutorial.
The problem for me is, in his tutorial he is using strings like this:
private static String url_all_products = "http://api.androidhive.info/android_connect/get_all_products.php";
to run his php scripts in a call to makeHttpRequest(url_all_products). But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
Next, I have a test.php file that does a simple echo statement and it works when I run this in a web browser:
http://localhost/phpfiles/test.php
Which leads me to my second problem. I don't want to use localhost because I need these php files and the ability to retrieve data from the database to be accessible to anyone using my app. This is the sole reason I'm using Amazon's RDS service so my database can be accessed on the cloud.
So how can I use the host address provided to me by Amazon RDS to access the database and where do I store all the php files so I can properly use them in Android the way the tutorial shows? They are currently saved in xampp/htdocs/phpfiles/.
I feel like I'm missing some fundamental understanding of all this and I'm going about it all wrong. If someone can point me in the right direction that would make my day.
It sounds like you don't really need the XAMPP install on your local machine at all. You're hosting this on Amazon and you want it to be available to the internet, so your local computer isn't involved. You can use XAMPP locally for testing and development, but for production use you'll be exclusively on the Amazon RDS cloud.
But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
You may not want a website, but you do want your services hosted on the internet. That's what your RDS instance is for, and technically the tutorial is referring to an API which happens to be exposed through a web page. This is a much better idea than opening MySQL directly to the internet on port 3306.
You'll then use your Amazon host — for which you really should use a FQDN such as api.example.com rather than the IP address, but the IP address will work just fine from a technical aspect.
The files you refer to are on your local XAMPP installation; in the xampp/htdocs/phpfiles/ folder, and need to instead be on the RDS instance.
Then your application accesses the API you expose in those files which return information back to your application.

How to connect VB.NET to Web Host

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

Hyperedit, php and mysql

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.

Categories