Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 08:22, 31 July 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Setup MySQL in WAMP - password setting, service shutdown & startup

From Wiki
Jump to: navigation, search
Article Metadata
Created: Maveric (25 May 2010)
Last edited: hamishwillee (31 Jul 2012)



The MySQL is a powerful relational database system coming as a preinstalled service with WAMP installation. After reading this article, you should be able to replace the root user default password with your own, check if the MySQL database service is running, shutdown the MySQL database service and bring it up running again.


You have installed the WAMP for Windows, similarly as in the Wiki article: How to install WAMP on Windows

Start the MySQL console

The MySQL console can be opened from the WAMP menu.

Alternatively you could navigate to the directory below and launch “mysql” from command prompt.

... C:\wamp\bin\mysql\mysql5.1.36\bin> ...

Note :

We could also utilize the phpMyAdmin console, a general all-rounder tool, but it is good also to gain some touch on working with the plain console, as sometimes it is even a bit clearer to perform certain tasks with. The phpMyAdmin Interface will be handled in another Wiki article.

Reset administrator (root) password

MySQL is setup default so, that the admin user name is "root" and the password is empty. Therefore the MySQL will treat you as user “root” and you can login first time by hitting the <Enter>key only. The first operation would be to change this default password for security reasons.

On the Windows console screen the following message appears:

... Enter password: ...

Just press ENTER to continue, no password is to be given. The MySQL monitor will show the following greeting:

... Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.36-community-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ...

At the "mysql>" command prompt, enter the following line, and press ENTER.

Note: below, the "<your_password>" means the password you want to take in use, so please replace it with the one you want. Remember to keep the ' symbols around the password. In this article only will be used password “dba”

... SET PASSWORD FOR root@localhost=PASSWORD('dba'); ...

A successful password change will result in the following message (time consumed may differ per case).

... Query OK, 0 rows affected (0.03 sec) mysql> ...

Remember to renew your root password periodically

The password should be renewed periodically. If the MySQL database service is running, you can update a new password as follows:

... mysql> use mysql Database changed mysql> UPDATE user SET Password = PASSWORD('dba') WHERE User = 'root'; Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 ...

If you attempting to set new root password while MySQL database service is running and just plain use the “set password” command, you will encounter an error:

... mysql> set password for root @localhost=PASSWORD('dba'); ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> ...

You would need to first shut down the MySQL database service from WAMP menu (left-click on the desktop icon, select “MySQL”, “Service”, “Stop service”).

MySQL shutdown & startup & password test at console

First let’s bring down the MySQL database service. For this you should Change to the directory \bin where the tool called “mysqladmin.exe” resides. Then provide to it the root username and password with command “shutdown”, as follows:

... C:\wamp\bin\mysql\mysql5.1.36\bin>mysqladmin -u root shutdown -p Enter password: ***

C:\wamp\bin\mysql\mysql5.1.36\bin> ...

You can then verify that the service has been shutdown by attempting to login:

... C:\wamp\bin\mysql\mysql5.1.36\bin>mysql -u root -p Enter password: *** ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061) ...

Let’s startup the service and try again. Open another command window and change to the “C:\wamp\bin\mysql\mysql5.1.36\bin>” directory, then enter:

... C:\wamp\bin\mysql\mysql5.1.36\bin>mysqld ...

Go back to the first command window and type in:

... C:\wamp\bin\mysql\mysql5.1.36\bin>mysql -u root -p

Enter password: ***

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.36-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ...

After you have successfully been logged in, you can close the second command window.

Note: You could also use the Windows WAMP menu; use Left mouse click over the WampServer icon in the Windows Task bar. Then open MySQL -> Service -> Start/Resume Service.

Related Articles

Articles on How to install WAMP and MySQL server to create Mobile server use

--Maveric 12:02, 25 May 2010 (UTC)

This page was last modified on 31 July 2012, at 08:22.
2377 page views in the last 30 days.