You will need to give root@localhost a password
Since you just installed mysql, you are running with default settings, this means you have no my.cnf. You will have to create one.
Run the following at a DIS Prompt
cd C:\Program Files\MySQL\MySQL Server 5.5
dir *.ini
There, you will see sample .ini
files. Let's pick my-small.ini
net stop mysql
cd C:\Program Files\MySQL\MySQL Server 5.5
copy my-small.ini my.ini
cd data
del ib*
notepad my.ini
Once you open notepad, add this under the [mysqld] header
[mysqld]
skip-grant-tables
Close notepad and Save my.ini
Next, run these lines
net start mysql
mysql (hit enter)
You will get a mysql prompt. Now run this:
mysql> UPDATE mysql.user SET PASSWORD=PASSWORD('mysecretpassword') WHERE user='root' AND host='localhost';
exit
Back at the DOS Prompt, do this:
net stop mysql
notepad my.ini
Once Notepad is open, delete the line skip-grant-tables
from my.ini
Close notepad and Save my.ini
net start mysql
Once mysql is back up, test the password at the DOS prompt
mysql -uroot -p (hit enter)
Password: (type mysecretpassword and hit enter)
If you get the mysql prompt, CONGRATULATIONS !!! You installed a password for root@localhost
Go back to MySQL Workbench and user mysecretpassword
as the password
Give it a Try !!!
Best Answer
If you installed MySQL as a service, you need the following:
STEP 01
Open Windows Command Line as Administrator and run
STEP 02
Add this to
C:\Program Files (x86)\MySQL\MySQL 5.7\my.ini
under the[mysqld]
group headerSTEP 03
You should be logged into mysql
STEP 04
Suppose you want root@localhost's password to be
hello
, run thisSTEP 05
STEP 06
Remove the
skip-grant-tables
option from themy.ini
STEP 07
STEP 08
This should prompt you for the password. Enter new password and you should be in.
ALTERNATIVE
Instead of creating
my.ini
, do the following after you have shutdown MySQLYou should now be inside mysql without a password. Next run this
Back at the command line, shutdown mysql like this:
Now, you start MySQL57 Service back up