Find the answer to your Linux question:
Results 1 to 9 of 9
Hello, I just set a password for mysql in Ubuntu webmin and when i enter that it returns error. I try some methods but one of them was better. I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2013
    Posts
    6

    I forget the mysql password and cant change it


    Hello,

    I just set a password for mysql in Ubuntu webmin and when i enter that it returns error.

    I try some methods but one of them was better.
    I try this codes:

    1. /etc/init.d/mysql stop (done without error)
    2. mysqld_safe --skip-grant-tables & (done without error)
    3. mysql -u root (connect to mysql)
    4. use mysql;
    update user set password=PASSWORD(“PASSWORD”)
    where User=’root’;
    flush privileges;
    quit;

    also step 4 done completely and i receive these massages :
    "Query OK, 3 rows affected (0.00 sec)
    Rows matched: 3 Changed: 3 Warnings: 0

    Query OK, 0 rows affected (0.00 sec)

    Bye"

    finally I reset mysql with these two commands :
    /etc/init.d/mysql stop
    /etc/init.d/mysql start

    but when i use the command "mysql -u root -p" to enter the passwort it says : "access denied for user root at localhost (using password: yes)"

    why I cant enter now ? does anyone have solution or another method for this?

  2. #2
    Linux User
    Join Date
    Dec 2009
    Posts
    264
    Quote Originally Posted by saeeds255 View Post
    4. use mysql;
    update user set password=PASSWORD(“PASSWORD”)
    where User=’root’;
    flush privileges;
    quit;
    Sry, to ask this, but I hope you know that you need to replace "PASSWORD" with the password you want?
    Just asking to make sure.

    My first guess would be a coding problem.
    So try it with an easy password (if it is just reachable from the local network).
    If it works you need to look into the character-set settings.
    --- If the easy password doesn't work you may wanna look into the table:
    4. use mysql;
    select * from user where User='root';

    Will show you the user entries.

  3. #3
    Just Joined!
    Join Date
    Nov 2013
    Posts
    6
    Quote Originally Posted by zombykillah View Post
    Sry, to ask this, but I hope you know that you need to replace "PASSWORD" with the password you want?
    Just asking to make sure.

    My first guess would be a coding problem.
    So try it with an easy password (if it is just reachable from the local network).
    If it works you need to look into the character-set settings.
    --- If the easy password doesn't work you may wanna look into the table:
    4. use mysql;
    select * from user where User='root';

    Will show you the user entries.
    I just use this command : password=PASSWORD("");
    then select user , password , host from user;
    and I saw that the password of all users is blank but when i want to enter mysql (after restarting mysql) i get this error :

    "Re: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)"

    why I cant login when I dont set any password ?

    please help me, thanks a lot ...

  4. #4
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    943
    Quote Originally Posted by saeeds255 View Post
    I just use this command : password=PASSWORD("");
    then select user , password , host from user;
    and I saw that the password of all users is blank but when i want to enter mysql (after restarting mysql) i get this error :

    "Re: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)"

    why I cant login when I dont set any password ?

    please help me, thanks a lot ...
    Did you try starting mysql with the -p and then just hit enter for blank password when prompted?

  5. #5
    Just Joined!
    Join Date
    Nov 2013
    Posts
    6
    Quote Originally Posted by docbop View Post
    Did you try starting mysql with the -p and then just hit enter for blank password when prompted?
    yes I also try that and got error

  6. #6
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    943
    Quote Originally Posted by saeeds255 View Post
    yes I also try that and got error
    I've done it in the past a few times. Here's the process I used like recommended before.

    https://dev.mysql.com/doc/refman/5.0...rmissions.html

  7. #7
    Just Joined!
    Join Date
    Nov 2013
    Posts
    6
    Quote Originally Posted by docbop View Post
    I've done it in the past a few times. Here's the process I used like recommended before.
    the way that you introduced is the same as mine.
    you know my problem is just that I cant enter to a mysql that hasnt any password. in spite of it hasnt password but asks me to enter the password !!

    how can I completely remove mysql with all of its data then install it again ?
    I removed and reinstall it through wembin but the password didnt change.

  8. #8
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    943
    Quote Originally Posted by saeeds255 View Post
    the way that you introduced is the same as mine.
    you know my problem is just that I cant enter to a mysql that hasnt any password. in spite of it hasnt password but asks me to enter the password !!

    how can I completely remove mysql with all of its data then install it again ?
    I removed and reinstall it through wembin but the password didnt change.
    I've had to do it a few times and I used the Debian dpkg package tool with the --purge so it wipes all the config files. Here's the link to the man page for dpkg:

    Ubuntu Manpage: dpkg - package manager for Debian

    I don't use the GUI tools because sometimes they don't always clean all the files out.

    If you want a GUI for MySQL take a look at MyPHPAdmin there is a Ubuntu package for it, It's a web-based GUI that handles both basic and advanced MySQL configs.

  9. #9
    Just Joined!
    Join Date
    Nov 2013
    Posts
    6
    Quote Originally Posted by docbop View Post
    I've had to do it a few times and I used the Debian dpkg package tool with the --purge so it wipes all the config files. Here's the link to the man page for dpkg:


    I don't use the GUI tools because sometimes they don't always clean all the files out.

    If you want a GUI for MySQL take a look at MyPHPAdmin there is a Ubuntu package for it, It's a web-based GUI that handles both basic and advanced MySQL configs.
    no need to that, I made it this way :

    this way I could solve it :

    ( mysqld_safe --skip-grant-tables &
    - mysql -u root
    - use mysql;
    - GRANT ALL PRIVILEGES ON *.* TO 'root' at 'localhost' IDENTIFIED BY 'password';
    - SET PASSWORD FOR 'root' at 'localhost' = PASSWORD('password'); ~~> I think this part is not needed but i use it.
    - flush privileges; ~~> this part is not needed i just add it for fun
    - quit )

    thank to all the users that helped me, I think its a good experience.

Posting Permissions

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