MySQL study notes. Other

MySQL change password

1. Use the SET PASSWORD command to modify
this method is not suitable for forgotten password
login mysql input command:set password for 用户名@localhost = password('新密码');

C:\Users\acer>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.1.60-community-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> set password for root@localhost=password('python');
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

C:\Users\acer>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.1.60-community-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

2. Use mysqladmin to modify the password.
This method does not need to log in to mysql, change the password python to root, but it is also not suitable for forgetting the password

C:\Users\acer>mysqladmin -u root -ppython password root

C:\Users\acer>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.1.60-community-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

3. Use UPDATE to edit the user table to modify the password.
This method requires logging in to mysql, and it is also not suitable for forgetting the password

mysql> use mysql;
Database changed
mysql> update user set password=password('python') where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

flush privileges; Refresh permissions
At this time, the password has been changed to python
4. How do I change the password if I forget it?
I checked a lot and summarized as follows
. The first method:
enter the mysql installation directory and find the my.ini file, open Notepad, and add skip-grant-tables under mysqld. The purpose is to skip the authorization table authentication, so that you can log in without password. .
Insert picture description here

After modification, restart the mysql service (service mysql restart)

C:\Users\acer>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.1.60-community-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Enter mysql -u root -p will pop up the enter password here: press Enter and you will enter mysql. At this time, delete the added skip-grant-tables
Insert picture description here
and save after deleting.
change Password

mysql> use mysql;
Database changed
mysql> update user set password=password("root") where user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2  Changed: 0  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Then restart the mysql service.

C:\Users\acer>mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

C:\Users\acer>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.1.60-community-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

At this time, you can enter mysql directly like the previous one, and you can only enter the correct password.
The second method: Although it is very practical, it is not recommended.
Needless to say , reinstall mysql and reinstall.

MySQL Visualization Tool Navicat

I use Navicat12, and now I put the link of the installation package and its tools below.
https://pan.baidu.com/s/1sJtjRh41pOS-9quDyjTd3g
Extraction code: snsm

MySQL installation package

What I use is relatively old, and it is also given by the teacher. The mysql5.0 version is very easy to use anyway, at least it is not as laborious as other versions. The installation package and installation tutorial are also attached.
https://pan.baidu.com/s/1Ty-G2T_z8qGjZFHyVkq15Q
Extraction code: dhlt


Summary and some words

In fact, there are a lot of things I want to say so far. I just finished writing this one and there are exactly 15 articles. I will make some conclusions here. There are many and many mysql learnings. I may also master that small part. Whether it’s use or learning, I will continue to go deeper. To be honest, no matter what you learn, you must have a humble spirit. There is no limit to learning this kind of thing. When a person learns more You will find that you are actually more dishes, here is also a summary of this section of learning mysql.

I also want to say something to myself. During this period of time, I am actually quite confused. There are many things. No matter what, people always have to come bit by bit. I can’t rush. The fast pace of reality makes me more and more. The more impatient, some things must be done, and some things needn't be done. It is very important to distinguish them. This is also the truth that I have understood in a few days. Sometimes I am confused when faced with many, many problems. There are many things to learn and many things to do. . . If you don’t pass the hurdle, it will become history one day. No, history is a bit big, it should be said that it is part of my own experience. Maybe it fades over time, or maybe someday and some moment in the future vaguely remember so-and-so Someone.

I still remember the sentence in Su Shi's "Chibi Fu": Sending a mayfly to the world is a drop in the ocean. I mourn the need of my life, and envy the infinity of the Yangtze River. Suddenly you will be open-minded, and you will succeed if you work hard in the future. Live up to the time, live up to the years live up to this winter.

Guess you like

Origin blog.csdn.net/qq_44862120/article/details/109701067