先進入root模式:
sudo -s
1
1
然后輸入命令mysql
root@ubuntu:/home/cdd/Desktop/Django/typeidea-env/typeidea/typeidea# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.21-0ubuntu0.20.04.4 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
下面就是修改初始密碼的步驟:
現在mysql命令下輸入
mysql> use mysql
1
1
然后修改密碼:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '你的新密碼';
1
1
到這里新密碼就設置好了,下面我們登錄下:
$ mysql -u root -p
Enter password: # 這里輸入你的新密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 8.0.21-0ubuntu0.20.04.4 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mys