SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL Usernames/Passwords Basics

    I'm a relative newbie. I can make MySQL databases and tables and display dynamic tables on webpages. I'm about ready to publish my first database online. But I need to go back and get squared away on usernames and passwords.

    First, I'm going to run into a problem if my local username/password is star/stardust, but I want to use this database on sites with two different webhosts, which gave me the username riskybiz and laidoff, respectively.

    So could I replace the username and password with echo functions? For example, one of my webpages begins with the following code:

    <?php
    @mysql_connect ("localhost" , "testuser" ,
    "TestUser");
    @mysql_select_db ("world");

    Could I replace that with this?:

    <?php
    $username = 'webhost_testuser';
    $password = 'webhost_pass';
    $database = 'world';
    @mysql_connect ("localhost" , "' . $username . '" , "'
    . $password . '");
    @mysql_select_db ("database");

    But, going back to square one, I need to get a grip on the basics first. Let me
    break this down into three sections:

    1. What system do I have in operation now?
    2. What system SHOULD I have?
    3. How do I get there?

    I put some screen shots from a program called Navicat
    online at http://www.geoworld.org/userpass.gif

    In picture #1, you see my eight databases listed on
    the left. The tables inside database "world" are
    listed on the right.

    When I click "Manage Users," I see the following:

    %localhost
    geoblue_savior@%
    root@%
    root@localhost
    testuser@localhost

    I created geoblue_savior@% and testuser@localhost; one or more of the others are default usernames.

    Picture 5 illustrates that all eight databases appear inside each user's folder. So users can be thought of as people, and each of these people (in this particular case) has access to each database, right?

    Note the note at the bottom of picture 6:

    "No privileges are currently set for the selected option."

    So that's what I have. Now, what SHOULD I have, given the following?

    I'm the only person using my computer. I don't envision anyone else working with my databases, unless I create some tables that visitors can add information to using PHP add/edit forms.

    I'm going to have at least two major databases, one focusing on geography, the other on animals. I'll have others, but these will do as an example.

    Since I'm presently the only user, which of the following should/could I discard? In other words, let's say I choose "minx" as a new username, allowing me to discard testuser. And "minx" gives me access to both the World and Animals databases. Can I discard all the other usernames, or should I retain one or more?

    %localhost
    geoblue_savior@%
    root@%
    root@localhost
    testuser@localhost

    And what global privileges should I use?

    My final question is simple: How do you add and modify usernames and passwords with phpMyAdmin? I could have sworn I'd seen an option for changing passwords many times, but I can't find it now. It looks like I can do it with Navicat, but I'm going to be in trouble when my free trial runs out!

    Thanks.

  2. #2
    SitePoint Zealot Pie's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First things, dont use @'s, @s mean that the function does NOT return an error. You want to know if it cant connect to the mysql server/database.

    Yes you could replace them, but in all honesty its better to use the define variable.

    Carry on using phpmyadmin, how are you storing your usernames and passwords? do you md5 them or is it plain text?
    Zach Inglis
    Reality Art Studios Ltd
    ZachInglis.com Blog |
    Art / Code Chat & Tutorials | Work

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To your first question. Try this connection code instead:
    PHP Code:
    $server 'localhost';
    $username 'webhost_testuser';
    $password 'webhost_pass';
    $database 'world';

    $dbconnection mysql_connect($server $username $password) or die(mysql_error());
    mysql_select_db($database) or die(mysql_error()); 
    -Helge


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •