-
MySQL User Access
Hello from a very green MySQL newbie. I am designing a web application that will enable users to register for an event. In reviewing the MySQL 4.1 manual, it indicates that users must be granted permission to access database tables. How does this work in a situation where multiple users will be hitting the database tables at any given time? Is there an anonymous user access that can be granted? My apologies if I'm not being clear with my question. I'm a very green newbie to MySQL. Thanks, in advance, for your assistance.
-
Hello,
Your users will be accessing the database directly????? You shouldn't allow direct access to the database for not only security reasons but for the general integrity of your database(s).
Typically, you will set up a user and that user will be used to access the database/tables/etc. through an interface for the specific application (with appropriate limited privs of course). This user is used within your application to execute the specified/limited set of inserts, updates, etc.
-
Thanks for the information. I'll create a generic user with limited priviliges. I would then reference this username in my scripting, correct? Can you direct me to any script examples that address this? Thanks
-
Hi,
What language(s) would you like examples in?
-
PhxVyper,
I'll be using PHP. Thanks for your help!!
-
here is an example:
PHP Code:
<?php
if(!$dbConn = @mysql_connect('host','user','pass'))
{
$error = mysql_error();
}
else
{
$sql = "SELECT * FROM MYTABLE WHERE 1";
if(!$resultSet = @mysql_query($sql,$dbConn))
{
$error = mysql_error();
}
else
{
while($record = @mysql_fetch_array($resultSet))
{
/** do stuff with your records */
/** for example... */
echo "First Name: ".$record['first_name']."<br />";
/** where first_name is the name of the field in MYTABLE */
}
}
}
if(isset($error) && $error != "")
{
echo $error;
}
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|