How to change the password of MYSQLADMIN after you forget the password of mysqlroot

Source: Internet
Author: User
Tags mysql create mysql create table
In general, forgetting the password is a new mysql novice friend. Let's show you how to use mysqadmin to change the password.

In general, forgetting the password is a new mysql novice friend. Let's show you how to use mysqadmin to change the password.

I believe that I will understand it soon.
1. The original password is 123456.
C:> type 5.bat
@ Echo off
Mysql-uroot-p123456-P3306
The correct format for modifying the MYSQL user password is:
We use
User: root (can be changed to another one)
Password: woshiduide
To demonstrate the new password.

The Code is as follows:
C:> mysqladmin-uroot-p password woshiduide
Enter password :******

The modification is successful.
Note the space behind the PASSWORD keyword

There are many people who have modified it like this:

The Code is as follows:

C:> mysqladmin-uroot-p password 'woshiduide'
Enter password :******

C:> mysqladmin-uroot-p password 'woshiduide'
Enter password :*********
Warning: single quotes were not trimmed from the password by your command
Line client, as you might have expected.

In this case, the real password is 'woshiduide'

The Code is as follows:

C:> mysql-uroot-p 'woshiduide'
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 18
Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)

Type 'help; 'or 'H' for help. Type 'C' to clear the buffer.

Mysql>

New users often do this:

The Code is as follows:
C:> mysql-uroot-pwoshiduide
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: Y
ES)

So it was very depressing. BAIDU and GOOGLE searched a lot.

Change the password.

The Code is as follows:
C:> mysqladmin-uroot-p 'woshiduide 'password 123456

2. You can directly access MYSQL and change the password.

The Code is as follows:

Mysql> use mysql
Database changed
Mysql> update user set PASSWORD = PASSWORD ('woshiduide ') where USER = 'root' and H
OST = 'localhost ';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Mysql> flush privileges;

Mysql> exit
Bye

C:> mysql-uroot-pwoshiduide
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 23
Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)

Type 'help; 'or 'H' for help. Type 'C' to clear the buffer.

Mysql>
Query OK, 0 rows affected (0.02 sec)

3. Use the set password command to modify the PASSWORD:

The Code is as follows:

C:> mysql5.bat
Enter password :******
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 8
Server version: 5.1.17-beta-community-nt-debug-log MySQL Community Server (GPL)

Type 'help; 'or 'H' for help. Type 'C' to clear the buffer.

Mysql> set password for root @ 'localhost' = password ('woshiduide ');
Query OK, 0 rows affected (0.02 sec)

Mysql> flush privileges;
Query OK, 0 rows affected (0.09 sec)

Mysql> exit
Bye
4. GRANT is acceptable, but it is not described here. Because of permission issues.

Usage of mysqladmin commands in mysql

Used to perform administrative operations. Syntax:
Shell>; mysqladmin [OPTIONS] command [command-option] command...
Run mysqladmin -- help to obtain a list of options supported by your mysqladmin version.
Currently, mysqladmin supports the following commands:
Create databasename create a new
Drop databasename delete a database and all its tables
Extended-status indicates an extended status message of the server.
Flush-hosts: cleans all cached hosts
Flush-logs clears all logs
Flush-tables: Remove all tables
Flush-privileges: Re-load the authorization table (same as reload)
Kill id, id,... kill mysql thread
Password: new password. Change the old password to a new password.
Ping to check if mysqld is alive
Processlist displays the list of active threads in the service.
Reload authorization table
Refresh cleans all tables and closes and opens log files.
Shutdown Server
Status indicates the brief status message of the server.
Variables: prints available variables.
Obtain the server version.
All commands can be shortened to their unique prefix. For example:
Shell>; mysqladmin proc stat
+ ---- + ------- + ----------- + ---- + ------------- + ------ + ------- + ------ +
| Id | User | Host | db | Command | Time | State | Info |
+ ---- + ------- + ----------- + ---- + ------------- + ------ + ------- + ------ +
| 6 | monty | localhost | Processlist | 0 |
+ ---- + ------- + ----------- + ---- + ------------- + ------ + ------- + ------ +
Uptime: 10077 Threads: 1 Questions: 9 Slow queries: 0 Opens: 6 Flush tables: 1
Open tables: 2 Memory in use: 1092 K Max memory used: 1116 K
The mysqladmin status command results in the following columns:
The number of seconds that the Uptime MySQL server has run
Number of Threads active Threads (customers)
Questions number of customer problems starting from mysqld
Slow queries has exceeded the number of queries in long_query_time seconds.
How many tables does Opens mysqld open?
Flush tables flush..., number of refresh and reload commands
Number of Open tables currently opened
Memory in use Memory directly allocated by mysqld code (available only when MySQL is compiled using -- with-debug)
Max memory used the maximum memory directly allocated by mysqld code (only available when MySQL is compiled using -- with-debug)
It is mainly used for management. If it is not used, go to mysql create table directly.
Or mysqldmin create database
./***. SQL (this is an exported or self-Written Statement)

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.