How to Change MySQL root password on Windows
Use these instructions if you need change the root password for MySQL on Windows or if you need to add additional new users with general or specific limitations.
Setting a root password for MySQL
- Start your command line by going to the Start Menu > Run and typing cmd (or type command if you are using an older version of windows)
- Change directory to where you installed mysql to:
C:\> cd C:\mysql\bin - Switch to mysql command line:
C:\mysql\bin> mysql -u root mysql - Then set a default password:
mysql> SET PASSWORD FOR root@localhost=PASSWORD('newpass');
where "newpass" is the password you want to use
Adding more users
- Start your command line by going to the Start Menu > Run and typing cmd (or type command if you are using an older version of windows)
- Change directory to where you installed mysql to:
C:\> cd C:\mysql\bin - Switch to mysql command line (if you have not set a root password remove the -p switch when you type it in):
C:\mysql\bin> mysql -u root -p mysql - Then then add your new user:
mysql> CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
where "jeffrey" is the username and "mypass" is the password you want to use. You can also limit users to specific database, allow only certain remote hosts to connect all using the GRANT statement. However, that is outside the scope of this tutorial so search for more info on using GRANT if you are interested in those features.