SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql_connect question

    I am going through Kevin Yanks' tutorial. I'm on Part 4: Publising MySQL Data on the Web.

    Right now I'm just working on my local server to test out and mess around with the .php files. Anyways, in the .php file I'm supposed to connect to MySQL. It says to type:

    PHP Code:
    mysql_connect(<address>, <username>, <password>); 
    I have this so far:

    PHP Code:
    mysql_connect("localhost""Adam", <password>); 
    Where I can I find the password? I'm not sure what it is?
    And is what I already have correct? (the address part)

    Thanks!
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok - this is the sort of thing you tend to configure once then forget about. So, my memory of users and user permissions is a bit shakey! However, when you install MySql you should also install a database named MySQL and possibly another one named Test - this probably happened automatically with whatever install scripts or bundled distro you used.

    Inside database MySQL is a table named Users. This holds the user accounts for the mysql server. By default a user 'root' will be defined with no password.

    To secure root access to the mysql server you normally use the mysqladmin binary to set a password for the root user. I am not familiar with what utility programs come with mysql for windows and how they work. But on linux you would do something like

    mysqladmin -u root password xxxxxx

    where xxxxxx is the password you are setting for root.

    Now to add further users to the user table you need to fire up the mysql client on the command line and execute a GRANT query which is expalained here http://www.mysql.com/doc/A/d/Adding_users.html

    I am sure that Kevin Yank's tutorial would also cover this, as setting up the users is naturally something everyone needs to do as a post-installation activity.

    eg:

    GRANT ALL PRIVILEGES ON *.* TO Adam@localhost
    IDENTIFIED BY 'xxxxxx' WITH GRANT OPTION;

    where xxxxx is your password.

  3. #3
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great. The users table is where everything was. You were right, the username was "root" with no password.

    I saw this table:

    Field | Type | Attributes | Null | Default | Extra | Action
    Host char(60) No Change Drop Primary Index Unique
    User char(16) No Change Drop Primary Index Unique
    Password char(16) No Change Drop Primary Index Unique
    Select_priv enum('N','Y') No N Change Drop Primary Index Unique
    Insert_priv enum('N','Y') No N Change Drop Primary Index Unique
    Update_priv enum('N','Y') No N Change Drop Primary Index Unique
    Delete_priv enum('N','Y') No N Change Drop Primary Index Unique
    Create_priv enum('N','Y') No N Change Drop Primary Index Unique
    Drop_priv enum('N','Y') No N Change Drop Primary Index Unique
    Reload_priv enum('N','Y') No N Change Drop Primary Index Unique
    Shutdown_priv enum('N','Y') No N Change Drop Primary Index Unique
    Process_priv enum('N','Y') No N Change Drop Primary Index Unique
    File_priv enum('N','Y') No N Change Drop Primary Index Unique
    Grant_priv enum('N','Y') No N Change Drop Primary Index Unique
    References_priv enum('N','Y') No N Change Drop Primary Index Unique
    Index_priv enum('N','Y') No N Change Drop Primary Index Unique
    Alter_priv enum('N','Y') No N Change Drop Primary Index Unique

    Under this table was some words I could click. I click "Browse" and saw something like this:

    Host | User | Password | Select_priv | Insert_priv | Update_priv | etc.
    localhost | root | | Y | Y | Y | Edit |Delete
    % | | | Y | Y | Y | Edit |Delete
    localhost | root | | Y | Y | Y | Edit |Delete
    % | | | Y | Y | Y | Edit |Delete

    Should I change the password in one of these so that I do have a password?
    Last edited by Adam P.; Aug 30, 2001 at 20:01.
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  4. #4
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Adam, I simply use root w/ no password on my machine. Then when I upload the script to my web server, I simply change the host, username, and password accordingly. It works well for me. But I think I may try freakysid's suggestions.

    freakysid, one question (kind of a side note), how would I be able to make all of my databases on my computer, and then simply upload the database to my host? I've been wanting to be able to do that, but haven't been able to figure out how.

    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  5. #5
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    swimm as Aes says, you probably aren't to concerned with security and setting passwords on your local devlopment box - so its up to you what you do. But its better to use mysqladmin like I suggested to change user passwords or if you want to execute a UPDATE query on table user then you should set the password using PASSWORD(yournewpword) because mysql stores the passwords using one-way encryption.

    UPDATE user SET Password=PASSWORD('newpassword')
    WHERE User='root'

    Aes I should know these things better than I do. There are plenty of regulars here that will be able to answer this better. You probably can upload the appropiate files for the database and its tables and place them in the appropriate directory which will be either (I think):

    /pathto/mysql/var/
    or
    /pathto/mysql/data/

    Under which will be a directory for each database inside whidh will be all the files for that database. But the problem with just copying over files like that is that if you need special permissions set in the mysql.permissions table for your database then they are not going to be migrated over (unless you copy the mysql database too I suppose).

    Or you can use mysqldump too, I guess. I don't know enough about this. I should know more. The only times I have transfered a mysql database from one server to another was to create a dump of all the table strucutres and data and load it from file either using the mysql client on the command line or through a php utility script. But for bid databases (such as a vB database) I'm sure it would be easier to tar and zip the data directory and copy the whole damned thing. I remember prequel mentioning that he had done this recently. He might have some better advice.

    I think we need an expert to answerthis one
    Last edited by freakysid; Aug 30, 2001 at 21:50.

  6. #6
    SitePoint Enthusiast cragthehack's Avatar
    Join Date
    Jul 2001
    Location
    Ft. Lauderdale, FL. USA
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check out phpmyadmin. PHPmyadmin is a web administration system for MySQL Databases, and provides you the ability to create, amend, delete and dump tables and whole databases. It is a tool many MySQL administrators use, especially in situations where TELNET access is not available





















    If you are using Dreamweaver UltraDev an extension is available that will install phpmyadmin into your site. Get it here: http://www.udzone.com/index.asp?TypeId=3&CatId=66 .





    Also, you will need the PHP server Model for UD to use it and all the other PHP extensions available. The server model, called PhaKt is also available on that site.











    For non Dreamweaver - get phpmyadmin at: http://phpmyadmin.sourceforge.net/









    crag

    PS. Be carefull using phpmyadmin. I usually delete it after i use it. If someone else got to it they can do serious damange.
    - crag
    net geek for non profits and political campaings

  7. #7
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks freakysid! I'll look into it!

    I all ready have PHPMyAdmin -- but don't know how to use it. I'll look into that as well.
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.


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
  •