It is not difficult for MySQL to change the root password

Source: Internet
Author: User
Tags import database

The following articles mainly introduce the practical application of the MySQL Command for modifying the root password, including the introduction of changing the root administrator password of the MySQL database and the command for changing the root password of the MySQL database, I hope it will help you in this regard.

1. How can I change the root administrator password of MySQL at the win2K command prompt?

 
 
  1. >MySQL -u root -p  
  2. Enter password: ******  
  3. MySQL> use MySQL;  
  4. MySQL> update user set passwordpassword=password('new_password') where user='root'; 

In this way, you can directly change the password of MySQL. If you can log on to MySQL under CMD, add "C: \ Program Files \ MySQL Server 5.0 \ bin;" to the PATH of the Windows environment variable).

Ii. MySQL root Password command

Switch to the MySQL installation directory under cmd

Example

D:/MySQL/bin

Prerequisites: the MySQL root Password is empty.

Enter MySQL-u root MySQL

MySQL> enter update user set password = password ('new password') where user = 'root ';

Echo

Query OK, 0 rows affected (0.00 sec)

Rows matched: 2 Changed: 0 Warnings: 0

MySQL> Status, enter flush privileges;

Echo

Query OK, 0 rows affected (0.00 sec)

MySQL> enter quit

Exit SQL

Note that a semicolon ";" must be added after each command ";"

MySQL started to execute this command

The second command updates the database of the MySQL system that has been loaded into the memory.

Restart MySQL.

After the root password is updated, the method for connecting to MySQL is as follows:

New MySQL-uroot-p Password

Forget the MySQL root Password:

First confirm that the MySQLd process has been killed, and then execute this

/Usr/bin/safe_MySQLd -- skip-grant-tables &

Then log on

MySQL-h 192.168.1.2-u root

The above 192.168.1.2 is the cloud's MySQLd running machine, you replace it with your own, so you can log on

You can change the password of MySQL.

Change Password

1. Run the MySQL-h hostname-u root command to log on to the MySQLd server and use the grant command to change the password:

Grant all on *. * to root indentified by "111111"

2. MySQLadmin-u username-p old password New password

Example 1: Add a password ab12 to the root user. First enter the directory MySQLbin in DOS, and then type

The following command

MySQLadmin-uroot password ab12

Note: because the root account does not have a password at the beginning, the old-p password can be omitted.

2. Example 2: Change the root password to djg345.

MySQLadmin-u root-pab12 password djg345

Write them together)

3.

 
 
  1. use MySQL; update user set passwordpassword =password('yourpass') where user='r   
  2. oot'  

4. Load the permission table: 'mysqladmin-h hostname flush-privileges', or

Run the SQL command 'flush privileges '. Of course, you can also restart MySQLd here .)

How to add data to a MySQL database:

 
 
  1. mysqi –u root   
  2. MySQL>create database ttt;   
  3. MySQL>source 1.txt   
  4. MySQL>load data local infile "2.txt" into table board;  

1. txt content:

 
 
  1. CREATE TABLE board (   
  2. boardid int(11) NOT NULL auto_increment,   
  3. boardname char(255),   
  4. PRIMARY KEY (boardid)   
  5. );  

2. txt content:

1 lk (separated by the Tab key)

2 lklk

3 lklklk

Export database:

# MySQLdump-opt ttt-uroot-p111111> 111. SQL

Import database

1. # MySQL-u root-p111111 ttt <111. SQL

2. MySQL> source 111. SQL;

Multiple exported databases: # MySQLdump -- databases ttt1 ttt2 ttt3-uroot-p111111

> 111. SQL

Export all databases: # MySQLdump -- all-databases-uroot-p111111> 111. SQL

Modify the root password of MySQL if you do not know the root password.

Add-skip-grant-tables when MySQLd is started, change the password immediately, remove-skip-grant-tables, and then OK.

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.