The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

N00b question: path to MySQL?

Discussion in 'Database Discussions' started by Decfor, Apr 11, 2006.

  1. Decfor

    Decfor Member

    Joined:
    Apr 11, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    hey, im a complete n00b to mySQL and indeed cpanel, and i have a question that probably doesnt even make sense. please bare with me.

    ok, so i'm an amateur flash and website designer, and pretty soon im gonna need to make some register and login forms for my site. these forms will obviously need to enter and retrieve information from a MySQL database.

    however, as stupid as this sounds, i cant find my MySQL databases on my server anywhere. i created them within CPanel, and i can edit and view them within cpanel and PhpMyAdmin.but when it comes to actually finding them, they dont seem to be anywhere. ive used File Manager to look in every folder possible (not just public_html) and i really do not know where they are.

    can anyone give me some idea as to where they might be, or the path to them?

    at first i though i would have to export the databases from within PhpMyAdmin, but im not sure if this correct, or how to do it


    can someone point me in the right direction please? and also - remember i'm a noob, so lamens terms please :)


    thanx in advance
     
  2. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Assuming Linux they would be in /var/lib/mysql.

    You can also use the "locate" command.
    locate "database name"
     
  3. Decfor

    Decfor Member

    Joined:
    Apr 11, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    i dont actually own the server, im hosted with www.ipaz.co.uk - and my PC is windows XP running firefox.

    i have FTP access via dreamweaver and smartFTP

    how do i do a locate c ommand - into what do i type it?

    also, /var/lib/mysql.

    is that www.mydomain.com/var/lib/mysql ?

    thanx a lot
     
  4. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    #4 sawbuck, Apr 11, 2006
    Last edited: Apr 11, 2006
  5. Decfor

    Decfor Member

    Joined:
    Apr 11, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    ok, im back.

    i now have a php script to connect to the database.
    i had some errors with connecting, but it wa just mis-spelt vartiable names.

    the script can connect to MySQL, but it says it cant find my database.

    i tried using a variable for the database, and just the database name, and nothi8ng seems to work.

    here is the script:
    PHP:
    <?
    $user="my_user";
    $password="my_pass";
    $database="andrew_logins";

    $first=$_POST['first'];
    $last=$_POST['last'];
    $phone=$_POST['phone'];
    $mobile=$_POST['mobile'];
    $fax=$_POST['fax'];
    $email=$_POST['email'];
    $web=$_POST['web'];

    mysql_connect(localhost,$user,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");

    $query "INSERT INTO contacts VALUES ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
    mysql_query($query);

    mysql_close();
    ?>
    i constantly get the "Unable to select database" error.

    ca anyone tell me why this may be?
     
  6. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    16
    most likely there is some problem with the username,password and database name combination.

    Ask your host; they should be able to look at your databases and see what is the problem.

    Or you can PM me and I'll take a look at it for you.
     
  7. d-woo

    d-woo Well-Known Member

    Joined:
    Aug 9, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Did you get this figured out?

    Possible error #1
    Sometimes in cpanel, the username and/or database name gets truncated if it is too long.

    e.g. if your account name is boston and your user name is massachussetts, cPanel will truncate your username to 16 characters max, so that if you look under the MySQL tab in cPanel, you will see boston_massachus as your username.

    You'll then need to correct this in your PHP script (s).

    Database names can be longer than 16 characters...so in this example if your goal was to have your username and database name be the same (not a bad practice for a newbie) then in your script you should have

    Code:
    $user="boston_massachus";
    $database="boston_massachussetts";
    $password="your_password";
    Possible error #2
    The other issue could be that in cPanel>>MySQL you created a username with password AND you created a database...

    BUT

    you have to remember to assign the user to the database.

    This is done in cPanel>>MySQL using the button "Add User to DB" after selecting the username and database names via the drop down lists above.
     
  8. Decfor

    Decfor Member

    Joined:
    Apr 11, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    did it guys :P


    i havent spent all this time attempting by the way, lol

    i went away on he night of the last post, and forgot about it. came back today, tried it once, and it worked.

    simple spelling mistake and i added the wrong user to database

    lol

    thanx anyways,x
     
Loading...

Share This Page