how access mysql remote database - iphone

i m creating inapp purchage subscription module,
in this app i want to access remote database but problem is that how i connect
my objective-c code with the mysql on the server,
i am not found any sufficient refrence please help me if any refrence or solution is there.

In mySQL, all access from your application to the database server is already remote access. Local access is simply one case of remote access.
If you're working locally, you may be using "localhost" or "127.0.0.1" as the hostname for your data base, and 3306 as the port number. You're using the data base name you set up on your local server, perhaps "arunsdata" or some such thing
You need to find out the hostname and port number of the remote data base server. (The port number is probably 3306.) Then you need to modify your application code to specify that hostname and port number.
Before you do that you will need to have a username and password, and create your data base ("arunsdata" or whatever) on the remote data base and create your tables and other schema items. The administrator of the remote database server can probably help you with this.
Good luck! I remember how confusing this was the first time I faced it. It's simpler than it seems.

You should probably create a web service to access the remote mySQL server database. You can then send a request to the service using NSMutableURLRequest. If you need to return data back, return json since its more light weight than XML.

Related

Incremental data from Postgresql

I have a number of identical local postgreSql databases (identical in structure - not data) on several laptops that have intermittant access to internet. Records are being added to each DB daily. So Branch A,B,C each with a local Postgresql database. I would like all records from A,B,C in each table in a cloud Database.Also A,B,C data is separate - there is no overlap - A doesnt change B, or C etc. There are no duplicated unique keys.
NEED: I would like to collect all this data on a cloud based database by adding daily incremental data to a single cloud databse - so I can query the whole consolidated data using SQL and pull reports as needed.
Please can anyone point me in the right direction?
Thanks
It sounds like you want logical replication from each laptop to the cloud server. The problem there might be that contact must be made by the replica to each of the masters, so when your laptops are online, they would need to have predictable IP addresses so that they can be reached.
Maybe the best way around this is with a reverse SSH tunnel. On the central replica, you would tell it to subscribe to a publication hosted on some non-standard port on localhost. With a different port reserved for each laptop. So, for example, 9997, 9998, and 9999.
Then when each laptop has connectivity, it could run something like:
ssh rajb#1centralserver.example.com -R9999:localhost:5432 -f -N -T
This establishes an ssh connection to the central server (requiring a password, or private key, or however you have ssh set up) and sends instructions to the central server that whenever someone connects to port 9999 on the central server it should really send that connection back over ssh tunnel and hook it up to port 5432 (the default postgres server port) of the laptop.
For initially setting things up and debugging, you might want to omit the -f -N -T. That way, in addition to setting up the tunnel, you also get an interactive ssh session you can use for monitoring things.
Once the central service notices the connection is available, it will start downloading changes since the last time it could connect. When there is no connection, you will get a lot of nuisance messages to the log file as it checks each server every ~5 seconds to see if it is available.
From each laptop's perspective, the connection is coming from within, so the replication connection will use whatever authentication is set up or 127.0.0.1 or ::1, not the authentication set up for the actual remote IP.

Root password set & my IP entered at Network IP required, But unable to connect

The past similar questions have been related to mysql.
But this question is about using Google Cloud SQL, project name and access control, 1. set root password; then, 2. enter network IP.
From mysql workbench, "connect" command results in "access denied for user "root" nnn.nnn.nn.nnn (using password:YES).
Please help. I must be doing something wrong!
Your help much appreciated!!!
please double check that you enabled root password and that password is correct or try to change password.
If you get that error it means that your client (Mysql Workbech) can reach the SQL instance so networking and firewall rules are OK and even Cloud SQL access control is correctly set-up to receive request from your remote client IP otherwise you would receive a 'Lost connection at Mysql server' error.
Check e.g via whatismyipaddress.com that your client IP is not changing (Dynamic IP) and it is exactly the one you authorized in Cloud SQL access control.
Sincerely,
Paolo

Is PostgreSQL peer authentication safe for production?

PostgreSQL peer authentication is a source of many questions on this website, but once you understand how it works, it looks pretty awesome.
For example, I can have my application connecting to the development database without supplying username and password.
So, my question is, can I use peer authentication on a production server? Is it safe enough?
Thank you very much.
peer is very useful for many kinds of deployments - e.g. when you want to allow people to log in with local unix user accounts and get quick DB access as a matching PostgreSQL user.
It's not great for webapps, because you generally want each webapp to have its own user. So you usually use md5 for them.
I often combine the two. For webapps allow md5 to their private DB only - over local sockets if the driver supports it, otherwise over host connections from localhost. Allow peer for local users to any DB, including the webapp DBs. If you want to have only one user in each db (so you can ignore permissions - which I don't recommend, but I know some people do) you can use a pg_ident.conf mapping to allow people to authenticate via peer as users other than their default user name.
Then you may add hostssl connections from the outside world via md5 or gssapi (kerberos), or sspi if it's a Windows DB host.
Authentication methods aren't an all or nothing thing. There's a reason it's easy to provide a list of alternatives and pick the first matching one.

Can create a remote server with MongoDB? How?

My question, to be more clear, it is to create a server with mongodb on a cloud hosting (for example) and access it through another server.
Example:
I have a mobile app.
I hosted my mongoDB a cloud hosting (ubuntu).
I want to connect my app to the db on the server cloud.
Is it possible? How?
I'm joining this learning and my question was exactly MongoDB to create a server in a way that I could access it remotely.
Out of "localhost"? Different from all the tutorials I've seen.
From what you are describing, I think you want to implement a 2-Tier-Architecture. For practically all use cases, don't do it!
It's definitely possible, yes. You can open up the MongoDB port in your firewall. Let's say your computer has a fixed IP or a fixed name like mymongo.example.com. You can then connect to mongodb://mymongo.example.com:27017 (if you use the default port). But beware:
Security You need to make sure that clients can only perform those operations that you want to allow, e.g. using MongoDB integrated authentication, otherwise some random script kiddie will steal you database, delete it, or fill it with random data. Many servers, even if they don't host a well-known service, get attacked thousands of times per day. Also, you probably want to encrypt the connection so people can't spy on the connection. And to make it all worse, you will have to store the database credentials in your client app, which is practically impossible to do in a truly secure way.
Software architecture There is a ton of arguments against this architecture, but 1) alone should be enough. You never want to couple your client to the database, be it because of data migrations, software updates, security considerations, etc.
3-Tier
So what to do instead? Use a 3-Tier-Architecture: Host a server of some kind on mymongo.example.com that then connects to the database. That server could be implemented in nginx/node.js, iis/asp.net, apache/php, or whatever. It could even be a plain old C application (like many game servers).
The mongodb can still reside on yet a different machine, but when you use a server, the database credentials are only known to the server, not to all the clients.
Yes, it is possible. You would connect to MongoDB using the ip address of your host, or preferably using it's fully qualified hostname rather than "localhost". If you do that, you should secure your MongoDB installation otherwise anyone would be able to connect to your MongoDB instance. At an absolute minimum, enable MongoDB authentication. You should read up on MongoDB Security.
For a mobile application, you would probably have some sort of application server in front of MongoDB, e.g. your mobile application would not be connecting to MongoDB directly. In that case only your application server would be connecting to MongoDB, and you would secure MongoDB accordingly.

Accessing an external phpmyadmin on same network

I have a webshop running on a windows 2008 R2 server that can be accessed on a client PC in the same network.
It's working fine, but now I need to get the database from another windows 2008 server instead of running it on the same machine.
I've already installed WAMP on the new server, imported the database into phpmyadmin and opened port 80 for the firewall. In my connection file for the webshop I've changed the HOST to "192.168.0.17:80" (IP adress of the DB server).
I can still connect to the shop and use anything that doesn't use a database, but when I do need the database it loads for a while and it shows me a timeout error.
Pinging to the database from the Webhost server works.
Am I missing something?
Edit:
I can now access PHPMyAdmin from the Webserver through "192.168.0.17/phpmyadmin".
What would I have to enter in the PHP file to connect it to the database?
If you have phpMyAdmin and the webserver running on 192.168.0.17, and the database on, say, 192.168.0.20, then two things need to happen to allow phpMyAdmin to access the database.
MySQL needs to allow users to connect from other machines. By default, this usually is permitted; I'm not particularly sure what changes WAMP might make. If you've created users with host 'localhost', they won't work and you'll need to increase their permissions by modifying the host or creating a new similar user. The usual disclaimers apply about backing up first.
phpMyAdmin needs to be configured to look at the new MySQL server instead of localhost. Open up config.inc.php and edit or change the $cfg['Servers'][$i]['host']... line to read $cfg['Servers'][$i]['host'] = '192.168.0.20';
Once you've done that, you can open up the phpMyAdmin on your webserver and it should now attempt to connect to the other server that now has your MySQL server installed.
I've already installed WAMP on the new server, imported the database
into phpmyadmin and opened port 80 for the firewall. In my connection
file for the webshop I've changed the HOST to "192.168.0.17:80" (IP
adress of the DB server).
I'm not sure what this means. Your web application (what I presume you mean by "webshop") does need to know where the new database is, but port 80 is for web traffic, not MySQL connections (which are port 3306 by default).
One more little note:
In the title you mention "an external phpmyadmin", but in the case of networking as you describe "external" generally means "outside the local network" (which in turn generally means "anywhere on the internet"); I think you mean another machine on the same network which would be internal to your network.
Edit
I realized I'm more confused about your question than I thought, because you wrote
Edit: I can now access PHPMyAdmin from the Webserver through
"192.168.0.17/phpmyadmin".
Which doesn't make sense. I thought you have two servers, the webserver (which runs your web application and phpMyAdmin) and the database server. I am starting to suspect the webserver is actually 192.168.0.17, in which case you've correctly configured your phpMyAdmin to access the new MySQL server, so all you should have to do is update your web application to the proper IP address (without a port!); simply matching what you have in phpMyAdmin's config.inc.php. So instead of 192.168.17:80 as the host in your web application, you want the same hostname or IP address that phpMyAdmin is using to connect to. You can find that on the main page as well under the "Database server" section.