2

I downloaded MySQL no install package from official site and installed it on windows 7.

It works great but when I run mysql.exe I can use the tools as root without any password.

I am using windows 7 32 bit and I am using mysql-noinstall-5.0.96.

I want the root user to have a secure password. I want to create a root user or update the existing root user.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Alireza Saremi
  • 401
  • 1
  • 7
  • 13

2 Answers2

7

I have not used the install package you have used. However you can try the following. First check if the root user exists.

Execute the following code:

 SELECT User
        , Host
        , Password
 FROM mysql.user
 WHERE User='root'

This will return a list of the users with the root userid. You SHOULD have at least one root user listed there. If I am correct you will see root listed but the password column would be NULL or BLANK.

You would now need to set the password for the root users. There are a couple of ways you can do this the first way is to use the SET_PASSWORD method.

Example of SET_PASSWORD method:

 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');

The other way that is commonly used is the UPDATE Method.

Example of the UPDATE method:

 UPDATE mysql.user SET Password = PASSWORD('newpwd')
 WHERE User = 'root';
 FLUSH PRIVILEGES;

This method will update the mysql.user table directly and you would need to run the FLUSH PRIVILEGES to make sure the system security is reset.

If you dont have a root user you will need to create it.

This link is worth reading https://dev.mysql.com/doc/refman/5.5/en/default-privileges.html as it shows you all about default settings etc.

If you need to create a new user please check the following link http://dev.mysql.com/doc/refman/5.1/en/create-user.html.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Namphibian
  • 12,046
  • 7
  • 46
  • 76
  • Thank you Namphibian. That was really helpful. but something strange here. In this version of mysql there is no mysql database; Actually I use show databases to get list all existing database but there is just 2 database with name test and information schema. I download this version from official mysql site. any idea? Thanks again. – Alireza Saremi May 28 '12 at 18:50
  • 1
    Did you try and run the queries above? Did you get any errors? – Namphibian May 29 '12 at 06:42
  • my table doesn't have a password column............. how that happen o.O can i just add the column? – Fuseteam Sep 19 '19 at 18:00
  • ah it has a different name:https://stackoverflow.com/questions/16556497/how-to-reset-or-change-the-mysql-root-password#16556534 – Fuseteam Sep 19 '19 at 18:15
0

How to set the root user password for MySQL:

  1. Go to phpmyadmin you should be presented with a username/password login.

  2. Login as root. If you never set a root password during mysql installation then the password is blank. If you did set one, and you forgot what it is, then read: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html or blow away mysql and reinstall while paying attention to the set password dialog.

  3. Now you are logged in as root in phpmyadmin.

  4. Under General settings click "Change password" link.

  5. You are presented with a password reset popup box, type in your password twice to confirm and press "Go".

  6. The root password is now changed.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335