How to set the mysql root Password and mysqlroot Password

Source: Internet
Author: User

How to set the mysql root Password and mysqlroot Password
How to set the mysql root Password:


1. The initial password for installing root for the first time is blank. Note that there is no password. Press enter to enter
D: \ wamp \ bin \ mysql \ mysql5.6.17 \ bin>Mysql-uroot-p
Enter password: [Press Enter]
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 7
Server version: 5.6.17 MySQL Community Server (GPL)


Copyright (c) 2000,201 4, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.


Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.


Mysql>


2. Several Methods to change the root password:
1) use the set password command
First, log on to MySQL.
Format: mysql> set password for username @ localhost = password ('new password ');

For example:


Mysql> Set password for root @ localhost = password ('root ');
Query OK, 0 rows affected (0.00 sec)


Mysql> Quit
Bye


D: \ wamp \ bin \ mysql \ mysql5.6.17 \ bin> Mysql-uroot-proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 8
Server version: 5.6.17 MySQL Community Server (GPL)


Copyright (c) 2000,201 4, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.


Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.


Mysql>


2) use mysqladmin
Format: mysqladmin-u username-p old password New password
For example:
D: \ wamp \ bin \ mysql \ mysql5.6.17 \ bin> Mysqladmin-uroot-proot password root123
Warning: Using a password on the command line interface can be insecure.


D: \ wamp \ bin \ mysql \ mysql5.6.17 \ bin> Mysql-uroot-proot123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 10
Server version: 5.6.17 MySQL Community Server (GPL)


Copyright (c) 2000,201 4, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.


Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.


Mysql>


3) Use UPDATE to directly edit the user table
First, log on to MySQL.
   Mysql> use mysql;
Mysql> update user set password = password ('root') where user = 'root' and host = 'localhost ';
Mysql> flush privileges;

-- Be sure to flush privileges;
Mysql needs flush privileges to refresh the MySQL system permission table after setting a user or changing the password. Otherwise, access is denied. Another method is to restart the mysql server, to make the new settings take effect.


4) You can forget the root password.
Take windows as an example:
1. Disable the running MySQL service.
2. Open the DOS window and go to the mysql \ bin directory.
3. Enter mysqld -- skip-grant-tables and press Enter. -- Skip-grant-tables indicates that the permission table authentication is skipped when the MySQL service is started.
4. Open another DOS window (because the DOS window can no longer be moved) and go to the mysql \ bin directory.
5. Enter mysql and press Enter. If yes, the MySQL prompt> will appear.
6. Connect to the permission Database: use mysql ;.
6. Change the password: update user set password = password ('root123') where user = 'root'; (do not forget the last plus points ).
7. Refresh permission (required ): Flush privileges;
8. Exit quit current cmd and close the DOS window in 2.

9. log on to the DOS window in Step 4 with the username root and new password root123.


-----------------------------

Dylan Presents.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.