WebFaction
Community site: login faq

Hi, I need to write to a database from an applet which will be run by unknown users. Therefore I don't want to put a permanent password into the applet. Instead I'm trying to setup a temporary user in the php file that loads the applet, the pass the temporary username and password to the applet as parameters. It all works fine when I test on my PC using a localhost server.

But, when I upload to run from my website I'm getting database access problems and it may be a grant issue. Although the mysql_query to create the user grant doesn't generate an error there are no new users appearing in my database and the subsequent attempt to access the database fails.

Any ideas?

Thanks, stegzzz

asked 08 Apr '11, 10:17

stegzzz
17614
accept rate: 66%

sorry, the mysql_query to create the user grant does in fact generate an error, so the question is, why do my commands:

$query="CREATE USER '".$accesscode."'@'%' identified by '".$pass."'"; mysql_query($query);

fail?

(08 Apr '11, 10:26) stegzzz

The user created for your database doesn't have CREATE USER privileges. This is a limitation of our current database setup.

This is the next thing to be overhauled in our new control panel and I believe the ability to add users will be a part of this.

Until then, you'll have to install your own instance of MySQL in your home directory.

permanent link

answered 08 Apr '11, 10:54

David L ♦♦
1.4k13
accept rate: 45%

Thanks David. When I've installed, what address will I use to connect? Right now I use jdbc:mysql://web168.webfaction.com/+dbName but presumeably that would change.

(08 Apr '11, 12:15) stegzzz

First, if you build MySQL in your home directory, be sure to follow these steps.

If the applet is running on your WebFaction server, then you should use 'localhost' as the hostname, and include the port number assigned to your custom app, with whatever syntax your app requires for that.

If the applet is running remotely, like in the user's browser, then you'll need to get a dedicated IP ($5/month) and open a ticket to have us open the firewall for your custom MySQL port on your IP so that your applet will be able to connect to it.

(08 Apr '11, 12:24) seanf

One alternative method, which might be useful, is to employ a second database and use GRANT to allow access to another database. Information on that is available here.

permanent link

answered 26 Jun '11, 21:38

ryans ♦♦
5.0k93260
accept rate: 43%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×168

question asked: 08 Apr '11, 10:17

question was seen: 3,635 times

last updated: 26 Jun '11, 21:38

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM