Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: How to set mysql password

  1. #1

    Default How to set mysql password

    The normal way of setting a password for mysql does not work on opensuse 11.0

    localhost:/etc # mysqladmin -u root password xxx
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: YES)'
    Suse is using some strange /etc/my.cnf file which has the following section
    # The following options will be passed to all MySQL clients
    [client]
    #password =xxx
    port = 3306
    socket = /var/lib/mysql/mysql.sock
    Using this password entry changes the "password: YES" or "password: NO" answer.

    Now I am totally lost on configuring mysql and doing such simple tasks as setting of root password.

    Any help appreaciated, also any introduction into the how and why suse does it the way it works (which is different to usually).

  2. #2
    Join Date
    Jun 2008
    Location
    West Yorkshire, UK
    Posts
    3,431

    Default Re: How to set mysql password

    How far have you have in setting passwords? Normally mysql has no passwords set when it is installed. It also comes with an anonymous user which needs a password adding and both root and the anonymous user have accounts on both hosts.

    So you should simply start with -u root and add passwords for both root and the anonymous user or delete the anonymous user on both hosts.

    By the way how you log on is not recommended by mysql. Using -u <username> -p
    and then typing the password in at the prompt is the recommended way of logging in.

  3. #3
    Join Date
    Jun 2008
    Location
    relative
    Posts
    1,172

    Default Re: How to set mysql password

    Try this:
    Code:
    mysqladmin -u root -p password <new password here>
    mysqladmin will ask you for the root password. Leave the Enter password: empty If you haven't changed root password before.
    Good luck.
    http://mydailyhash.wordpress.com/
    http://yami.googlecode.com/

  4. #4

    Default Re: How to set mysql password

    Quote Originally Posted by john_hudson View Post
    How far have you have in setting passwords? Normally mysql has no passwords set when it is installed.
    As far as I know, not at all. Especially because all option on the commandline fail.


    Quote Originally Posted by john_hudson View Post
    So you should simply start with -u root and add passwords for both root and the anonymous user or delete the anonymous user on both hosts.
    Not possible
    localhost:/etc # mysql -u root
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    Quote Originally Posted by john_hudson View Post
    By the way how you log on is not recommended by mysql. Using -u <username> -p
    and then typing the password in at the prompt is the recommended way of logging in.
    I do not even want to log in. I have never ever logged in. I do not know a single sql command. I only want to set the password so that I can use phpmyadmin and install websystems such as wordpress.

    If it is totally messed - does it help to uninstall mysql?

  5. #5

    Default Re: How to set mysql password

    Quote Originally Posted by ram88 View Post
    Try this:
    Code:
    mysqladmin -u root -p password <new password here>
    mysqladmin will ask you for the root password. Leave the Enter password: empty If you haven't changed root password before.
    Good luck.
    Not possible:
    localhost:/etc # mysqladmin -u root -p password
    Enter password:
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: YES)'

  6. #6
    Join Date
    Dec 2008
    Location
    WI
    Posts
    32

    Default Re: How to set mysql password

    Where did you install mysql from? What version of openSUSE are you running?
    have you run the command "/etc/init.d/mysql status" as root?

  7. #7

    Default Re: How to set mysql password

    Quote Originally Posted by msounhein View Post
    Where did you install mysql from? What version of openSUSE are you running?
    have you run the command "/etc/init.d/mysql status" as root?
    Installed is
    localhost:/etc # rpm -qa | grep mysql
    libmysqlclient15-5.0.51a-27.1
    libqt4-sql-mysql-4.4.3-28.1
    mysql-tools-5.0.51a-27.1
    libmysqlclient_r15-5.0.51a-27.1
    perl-DBD-mysql-4.006-41.1
    mysql-gui-tools-5.0r12-195.1
    mysql-client-5.0.51a-27.1
    mysql-5.0.51a-27.1
    mysql-query-browser-5.0r12-195.1
    mysql-workbench-5.0r12-195.1
    php5-mysql-5.2.6-0.6
    mysql is installed from Main Repository (11.0)
    and 'status' results in

    localhost:/etc # /etc/init.d/mysql status
    Checking for service MySQL: running
    If (however) a password for root would be set, how could I reset that?

  8. #8
    Join Date
    Jun 2008
    Location
    relative
    Posts
    1,172

    Default Re: How to set mysql password

    If nothing helps, maybe something irregular happened...
    Please copy and paste this text:
    lost mysql root password
    into Google.
    http://mydailyhash.wordpress.com/
    http://yami.googlecode.com/

  9. #9

    Default Re: How to set mysql password

    I have been using this guide:
    Linux - Vergessenes root-Kennwort neu festlegen

    (german, but the commands should be clear)

    It worked, but now I cannot start mysql:
    localhost:/var/lib/mysql # /etc/init.d/mysql start
    Starting service MySQL warning: /var/lib/mysql/mysql.sock didn't appear within 30 seconds
    done

  10. #10
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: How to set mysql password

    Did you have any data already in /var/lib/mysql from a previous install?

    If you have never put any data in mysql before, a faster way to fix the root password is to delete /var/lib/mysql and reinstall the mysql package. Then set the password as documented, using

    mysqladmin -u root password new-password
    The non-italic words are typed as-is. Don't use -p this first time. -p is actually -p'' and implies you have already set a password, which you haven't, with a fresh install. It's ok to set the password on the command line this first time.

Page 1 of 3 123 LastLast

Posting Permissions

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