Results 1 to 6 of 6

Thread: MySQL User Access

  1. #1
    Join Date
    May 2006
    Posts
    4

    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.

  2. #2
    Join Date
    May 2006
    Posts
    3
    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.

  3. #3
    Join Date
    May 2006
    Posts
    4
    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

  4. #4
    Join Date
    May 2006
    Posts
    3
    Hi,

    What language(s) would you like examples in?

  5. #5
    Join Date
    May 2006
    Posts
    4
    PhxVyper,

    I'll be using PHP. Thanks for your help!!

  6. #6
    Join Date
    May 2006
    Posts
    3
    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
  •