Getting started with MySQL under Windows

from the Artful MySQL Tips List


To make life easier, create a desktop icon for a DOS window that opens in the mysql bin folder, eg if mysql is installed on c:, and if you accepted the defaults when installing version 5.1 of the server, your icon will open a DOS window over ...
C:\Program Files\MySQL\MySQL Server 5.7\bin
When you have that icon working, use it, then issue the command
net stop mysql
which will do what it says if MySQL is running as a network service. (If it is not, reboot the machine without any autoexec command that would start the server, then open a DOS window as above.) Now run
mysqld --skip-grant-tables
which starts the server without usernames & passwords. Now open a 2nd instance of your DOS window and issue this cmd:
mysql
to start the MySQL client, and in it issue
use mysql;
select host,user,password from user;
Inspect the list to see if there is a user named 'root'. If there is, its host is likely 'localhost', its password is likely blank, and if you have not edited the 'root' user row, 'root' has all possible privileges. Those are the privileges you want, but 'root' should have a password, so give her one, before 5.7.6 ...
UPDATE user
SET password=PASSWORD('yourdesiredpassword')
WHERE user='root';
... in 5.7 since 5.7.6 ...
UPDATE user
SET authentication_string=PASSWORD('yourdesiredpassword')
WHERE user='root';
and in 8.0, where the PASSWORD() function has been removed, use ALTER USER to reset the password...
ALTER USER 'root' IDENTIFIED BY 'yourdesiredpassword';
Then ...
FLUSH PRIVILEGES;
EXIT;
... and you should be able login from any host you've allowed for root.

If you have not installed MySQL as a service, do it now with

mysqld --install
Issue these DOS cmds:
mysqladmin shutdown
net start mysql
and you should be ready to roll.

Last updated 26 Oct 2020


Return to the Artful MySQL Tips page