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?
- >MySQL -u root -p
- Enter password: ******
- MySQL> use MySQL;
- 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.
- use MySQL; update user set passwordpassword =password('yourpass') where user='r
- 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:
- mysqi –u root
- MySQL>create database ttt;
- MySQL>source 1.txt
- MySQL>load data local infile "2.txt" into table board;
1. txt content:
- CREATE TABLE board (
- boardid int(11) NOT NULL auto_increment,
- boardname char(255),
- PRIMARY KEY (boardid)
- );
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.