mysql username and password


Results 1 to 10 of 10

Thread: mysql username and password

  1. #1
    Join Date
    Aug 2002
    Posts
    245

    mysql username and password

    how do i set a database username and password for mysql and a root password for all databases...??

    thx

  2. #2
    Join Date
    Aug 2002
    Posts
    70
    To set an initial root pass:

    mysqladmin -uroot password "newpasswd"

    To add user accounts, log into the mysql server as root and issue GRANT commands. Check the mysql docs for details.

  3. #3
    Join Date
    Oct 2003
    Posts
    48
    Banking off of this...

    Code:
    root@Orbital:/home/magelus# mysqladmin -u root password "*********"
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user: 'root@localhost' (Using password: NO)'
    shed any light onto this? This is a fresh install of mysql 4.0.22 installed from a slackware package (however, I've gotten the same issue with a source installation). Nothing in the manual handles this situation.

  4. #4
    Join Date
    Apr 2001
    Location
    Norway
    Posts
    344
    I think the syntax is:
    Code:
    #mysqladmin -u root -ppassword
    There is no space between -p and the password!

  5. #5
    Join Date
    Oct 2003
    Posts
    48
    Originally posted by truls
    I think the syntax is:
    Code:
    #mysqladmin -u root -ppassword
    There is no space between -p and the password!
    do you mean, replace "password" with my password? As in, if my password was goatcheese i would type
    Code:
    #mysqladmin -u root -pgoatcheese
    because there is no password to log into mysql (at least if there is, I have no clue what it is), it's a fresh install. I'm trying to set the root passwords for the first time, but its asking me for a password to change it... kind of a catch 22, eh?

  6. #6
    Join Date
    Apr 2001
    Location
    Norway
    Posts
    344
    The default password for mySQL is blank (i.e. no password). Try logging in using without the -p switch and then just press enter when it asks you for a password.

  7. #7
    Join Date
    Oct 2003
    Posts
    48
    Originally posted by truls
    The default password for mySQL is blank (i.e. no password). Try logging in using without the -p switch and then just press enter when it asks you for a password.
    Code:
    magelus@Orbital:~$ mysqladmin -u root -p password 'goatcheese'
    Enter password: 
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user: 'root@localhost' (Using password: NO)'
    magelus@Orbital:~$
    Last edited by ArtyMcSwizzle; 03-29-2005 at 12:44 PM.

  8. #8
    Join Date
    May 2000
    Location
    Redmond, WA - Home of the evil empire
    Posts
    80
    Also, remember to take out the space between the -u and root.
    Code:
    $ mysqladmin -uroot -pgoatcheese
    That should take you to the mysql screen providing you've set the password in the first place.

    Or, if you're trying to access the mysql database, you can also just do
    Code:
    $ mysqladmin -uroot
    That should just allow you to enter the password at the prompt after pressing enter.

    Just remember that if you're writing a shellscript for the this type of command...you CANNOT have the spaces between the -u and root or the -p and password. That took me about 3 hours to realize.

    I know, I know...I'm not the brightest crayon in the box.
    Optimum est pati quod emendare non possiss.

    Athlon XP 1.8 OC'd to 2.2 with 400 Mhz FSB
    1 Gig DDR
    128 Meg Radeon 9800 non-pro
    80 Gig HDD
    CDRW/CD-ROM/DVD-ROM combo drive

    Ubuntu Hoary
    Gentoo stage 1

  9. #9
    Join Date
    Oct 2003
    Posts
    48
    Okay I've tried all of this. With removing spaces and all, still no luck. Its demanding a password. I can't just use the p trigger and hit return on request for password, because then it errors out with "access denied... using password: NO"



    ...wait scratch that it was set to my local root password
    ...wow I'm a real genious here
    Thanks for your help, I'm going to go hide sheepishly in the corner now.

  10. #10
    Join Date
    May 2000
    Location
    Redmond, WA - Home of the evil empire
    Posts
    80
    Happens to the best of us man...I can't recall how many times I've done stupid stuff!

    Good luck!
    Optimum est pati quod emendare non possiss.

    Athlon XP 1.8 OC'd to 2.2 with 400 Mhz FSB
    1 Gig DDR
    128 Meg Radeon 9800 non-pro
    80 Gig HDD
    CDRW/CD-ROM/DVD-ROM combo drive

    Ubuntu Hoary
    Gentoo stage 1

Posting Permissions

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