Forget MySQL root password mysqladmin Modify password method

Source: Internet
Author: User
Tags flush mysql create create database mysql create table

I'll take a few examples and I'm sure I'll get it soon.
1, the original password is 123456
C:>type Mysql5.bat
@echo off
mysql-uroot-p123456-p3306
The correct format for modifying the MySQL user password is:
We use it here.
User: root (can be replaced by another)
Password: woshiduide
To demonstrate the new password.

The code is as follows Copy Code
C:>mysqladmin-uroot-p Password Woshiduide
Enter Password: Hu Jintao

So the modification succeeds.
Note the space following the password keyword

There are a lot of people who modify this:

The code is as follows Copy Code

c:>mysqladmin-uroot-p password ' woshiduide '
Enter Password: Hu Jintao

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.

And this time the real code is ' Woshiduide '

The code is as follows Copy Code

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>

And beginners tend to do this:

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

So very depressed, BAIDU, Google search a lot of.

I'll change the code back now.

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

2, there is a direct access to MySQL, and then modify the password.

  code is as follows copy code

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 Privileg es;

Mysql> exit
Bye

C:>mysql-uroot-pwoshiduide
Welcome to the MySQL monitor.  Commands ; or G.
Your MySQL connection ID is
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, another is to use the Set PASSWORD command to modify:

The code is as follows Copy Code

C:>mysql5.bat
Enter Password: Hu Jintao
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 also can, but this is not introduced. Because it involves the issue of permissions.

Introduction to mysqladmin command usage in MySQL

Used to perform administrative operations. The syntax is:
shell>; mysqladmin [OPTIONS] command [command-option] command ...
By executing mysqladmin--help, you can get a list of the options supported by your mysqladmin version.
Currently mysqladmin supports the following commands:
Create DatabaseName creates a new database
Drop DatabaseName Deletes a database and all its tables
Extended-status gives an extended status message to the server
Flush-hosts wash off all cached hosts
Flush-logs wash off all the logs.
Flush-tables wash off all the watches
Flush-privileges Load Authorization table again (same reload)
Kill Id,id,... Kill MySQL Thread
Password new password, change old password to new password
Ping Check if mysqld alive.
Processlist Display service List of active threads
Reload Overload Authorization Table
Refresh Erase all tables and close and open the log file
Shutdown, shut down the server.
Status gives a brief status message to the server
Variables print out available variables
Version gets the information about the server
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:1092k Max Memory used:1116k
The mysqladmin Status command results in the following columns:
Uptime the number of seconds the MySQL server has been running
Number of Threads active threads (Customers)
Questions number of customer issues initiated from mysqld
Slow queries number of queries that have exceeded long_query_time seconds
How many tables has the opens mysqld opened?
Flush tables Flush ..., refresh and reload command number
Open Table number of tables opened now
Memory in-use memory directly allocated by MYSQLD code (available only if MySQL is compiled with--with-debug)
Max memory used maximum memory allocated directly by MYSQLD code (only available when MySQL is compiled with--with-debug)
Mainly management is not used to use the words directly into the MySQL create table
You can also mysqldmin create database
./***.sql (This is an export or a written statement)

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.