溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么修改MySQL root用戶口令

發(fā)布時(shí)間:2021-12-04 09:51:17 來(lái)源:億速云 閱讀:260 作者:iii 欄目:MySQL數(shù)據(jù)庫(kù)

這篇文章主要講解了“怎么修改MySQL root用戶口令”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“怎么修改MySQL root用戶口令”吧!

1.一些基本概念

 1)MySQL體系結(jié)構(gòu)由五個(gè)主子系統(tǒng)組成:查詢引擎、存儲(chǔ)管理器、緩沖管理器、事務(wù)管理器和恢復(fù)管理器。
 2)查詢引擎包含三個(gè)相關(guān)聯(lián)的部件:語(yǔ)法分析器、查詢優(yōu)化器和執(zhí)行部件。
 3)除五個(gè)主子系統(tǒng)以外,MySQL體系結(jié)構(gòu)還包括兩個(gè)輔助部件:過(guò)程管理器和函數(shù)庫(kù)。
 4)在MySQL中,事務(wù)的開始標(biāo)記為一個(gè)BEGIN語(yǔ)句(與Oracle不同)。

2.安裝完成后修改MySQL root用戶口令

C:Documents and SettingsAdministrator>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 18
Server version: 5.1.34-community MySQL Community Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

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

mysql> quit
Bye

[@more@]C:Documents and SettingsAdministrator>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: N
O)

C:Documents and SettingsAdministrator>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 20
Server version: 5.1.34-community MySQL Community Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

3.修改數(shù)據(jù)文件存放路徑

   先關(guān)閉MySQL服務(wù)器

C:Documents and SettingsAdministrator>mysqladmin -u root -p shutdown
Enter password: ******

   修改my.ini配置文件(默認(rèn)放在 D:Program FilesMySQLMySQL Server 5.1 下)中的datadir參數(shù):

#Path to the database root
datadir="D:MySQL Datafilesdata"

   啟動(dòng)MySQL服務(wù)器,可以通過(guò)啟動(dòng)系統(tǒng)服務(wù)的方法。

4.一系列簡(jiǎn)單操作

 1)創(chuàng)建數(shù)據(jù)庫(kù),查看數(shù)據(jù)庫(kù),選擇想要使用的數(shù)據(jù)庫(kù)

mysql> create database ggyy;
Query OK, 1 row affected (0.43 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ggyy               |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ggyy               |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> use ggyy
Database changed

 2)創(chuàng)建表,查看表

mysql> create table members
   -> (
   -> id int(3) auto_increment,
   -> fname varchar(20) not null,
   -> lname varchar(20) not null,
   -> tel varchar(15),
   -> email varchar(50),
   -> primary key (id)
   -> );
Query OK, 0 rows affected (0.49 sec)

mysql> show tables;
+----------------+
| Tables_in_ggyy |
+----------------+
| members        |
+----------------+
1 row in set (0.01 sec)

注:auto_increment修飾符只適用于整型字段,表明MySQL將要為這個(gè)字段自動(dòng)生成一個(gè)數(shù)字(通過(guò)對(duì)前面的值增加1)。一個(gè)表只能有一個(gè)auto_increment字段,而且這個(gè)字段必須被定義為鍵(即字段上必須有索引,術(shù)語(yǔ)“鍵”和“索引”在MySQL中是等同的)。

   這時(shí)可以在數(shù)據(jù)文件的存放路徑下看到新生成的文件:

D:MySQL Datafilesdataggyy>dir
Volume in drive D is Data
Volume Serial Number is D632-9209

Directory of D:MySQL Datafilesdataggyy

2009-05-18  10:58

.
2009-05-18  10:58..
2009-05-18  10:18                65 db.opt
2009-05-18  10:36             8,680 members.frm
              2 File(s)          8,745 bytes
              2 Dir(s)  66,038,996,992 bytes free

 3)添加列,修改列,刪除列

mysql> desc members;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(3)      | NO   | PRI | NULL    | auto_increment |
| fname | varchar(20) | NO   |     | NULL    |                |
| lname | varchar(20) | NO   |     | NULL    |                |
| tel   | varchar(15) | YES  |     | NULL    |                |
| email | varchar(50) | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

mysql> alter table members add remark varchar(50);
Query OK, 0 rows affected (0.67 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc members;
+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int(3)      | NO   | PRI | NULL    | auto_increment |
| fname  | varchar(20) | NO   |     | NULL    |                |
| lname  | varchar(20) | NO   |     | NULL    |                |
| tel    | varchar(15) | YES  |     | NULL    |                |
| email  | varchar(50) | YES  |     | NULL    |                |
| remark | varchar(50) | YES  |     | NULL    |                |
+--------+-------------+------+-----+---------+----------------+
6 rows in set (0.04 sec)

mysql> alter table members modify remark varchar(100);
Query OK, 0 rows affected (0.18 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc members;
+--------+--------------+------+-----+---------+----------------+
| Field  | Type         | Null | Key | Default | Extra          |
+--------+--------------+------+-----+---------+----------------+
| id     | int(3)       | NO   | PRI | NULL    | auto_increment |
| fname  | varchar(20)  | NO   |     | NULL    |                |
| lname  | varchar(20)  | NO   |     | NULL    |                |
| tel    | varchar(15)  | YES  |     | NULL    |                |
| email  | varchar(50)  | YES  |     | NULL    |                |
| remark | varchar(100) | YES  |     | NULL    |                |
+--------+--------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)

mysql> alter table members drop remark;
Query OK, 0 rows affected (0.18 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc members;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(3)      | NO   | PRI | NULL    | auto_increment |
| fname | varchar(20) | NO   |     | NULL    |                |
| lname | varchar(20) | NO   |     | NULL    |                |
| tel   | varchar(15) | YES  |     | NULL    |                |
| email | varchar(50) | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

 4)插入記錄,查詢表,修改記錄,刪除記錄

mysql> insert into members (id, fname, lname, tel, email) values (1, 'Yue', 'Gao
', '1234567', 'yuegao@company.com');
Query OK, 1 row affected (0.07 sec)

mysql> insert into members values (3, 'Feng', 'Song', '7654321', 'fengsong@compa
ny.com');
Query OK, 1 row affected (0.43 sec)

mysql> select * from members;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com   |
|  3 | Feng  | Song  | 7654321 | fengsong@company.com |
+----+-------+-------+---------+----------------------+
2 rows in set (0.00 sec)

mysql> select * from members;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com   |
|  3 | Feng  | Song  | 7654321 | fengsong@company.com |
+----+-------+-------+---------+----------------------+
2 rows in set (0.01 sec)

mysql> insert into members (fname, lname, email) values ('Chen', 'Chu', 'chenchu
@company.com');
Query OK, 1 row affected (0.44 sec)

mysql> select * from members;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com   |
|  3 | Feng  | Song  | 7654321 | fengsong@company.com |
|  4 | Chen  | Chu   | NULL    | chenchu@company.com  |
+----+-------+-------+---------+----------------------+
3 rows in set (0.00 sec)

   這里可以看到auto_increment修飾符的作用,自動(dòng)將新插入的記錄id段的值設(shè)置為4,而不是2。

mysql> update members set id = 2 where id = 3;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from members;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com   |
|  2 | Feng  | Song  | 7654321 | fengsong@company.com |
|  4 | Chen  | Chu   | NULL    | chenchu@company.com  |
+----+-------+-------+---------+----------------------+
3 rows in set (0.00 sec)

mysql> delete from members where id = 4;
Query OK, 1 row affected (0.43 sec)

mysql> select * from members;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com   |
|  2 | Feng  | Song  | 7654321 | fengsong@company.com |
+----+-------+-------+---------+----------------------+
2 rows in set (0.00 sec)

mysql> insert into members (fname, lname, email) values ('Chen', 'Chu', 'chenchu
@company.com');
Query OK, 1 row affected (0.43 sec)

mysql> select * from members;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com   |
|  2 | Feng  | Song  | 7654321 | fengsong@company.com |
|  5 | Chen  | Chu   | NULL    | chenchu@company.com  |
+----+-------+-------+---------+----------------------+
3 rows in set (0.00 sec)

注:這里可以看到新插入的記錄id字段的值為5,即使表中已不存在id為3或4的記錄。也就是說(shuō),auto_increment修飾符不會(huì)重用那些曾經(jīng)使用過(guò)的值。

 5)limit關(guān)鍵字

   使用limit關(guān)鍵字可以對(duì)結(jié)果集進(jìn)行限制,它有兩個(gè)參數(shù),用逗號(hào)隔開,分別指定從哪行開始顯示和顯示多少行。如果只跟一個(gè)參數(shù),則指定從結(jié)果集合的開頭返回的行數(shù)。

mysql> select * from members limit 3,3;
Empty set (0.00 sec)

mysql> select * from members limit 2,3;
+----+-------+-------+------+---------------------+
| id | fname | lname | tel  | email               |
+----+-------+-------+------+---------------------+
|  5 | Chen  | Chu   | NULL | chenchu@company.com |
+----+-------+-------+------+---------------------+
1 row in set (0.01 sec)

mysql> select * from members limit 1, 3;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  2 | Feng  | Song  | 7654321 | fengsong@company.com |
|  5 | Chen  | Chu   | NULL    | chenchu@company.com  |
+----+-------+-------+---------+----------------------+
2 rows in set (0.00 sec)

mysql> select * from members limit 0, 3;
+----+-------+-------+---------+----------------------+
| id | fname | lname | tel     | email                |
+----+-------+-------+---------+----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com   |
|  2 | Feng  | Song  | 7654321 | fengsong@company.com |
|  5 | Chen  | Chu   | NULL    | chenchu@company.com  |
+----+-------+-------+---------+----------------------+
3 rows in set (0.00 sec)

   可以看到行號(hào)是從0開始的,并且3條記錄的行號(hào)是連續(xù)的。id為2的記錄是刪除后重新插入的,重新插入時(shí)id為5的記錄已經(jīng)存在,但id為2的記錄還是排在了前面。

mysql> insert into members values (6, 'Chao', 'Zhang', '6666666', 'chaozhang@com
pany.com');

mysql> select * from members limit 3,4;
+----+-------+-------+---------+-----------------------+
| id | fname | lname | tel     | email                 |
+----+-------+-------+---------+-----------------------+
|  6 | Chao  | Zhang | 6666666 | chaozhang@company.com |
+----+-------+-------+---------+-----------------------+
1 row in set (0.00 sec)

mysql> select * from members limit 2,4;
+----+-------+-------+---------+-----------------------+
| id | fname | lname | tel     | email                 |
+----+-------+-------+---------+-----------------------+
|  5 | Chen  | Chu   | NULL    | chenchu@company.com   |
|  6 | Chao  | Zhang | 6666666 | chaozhang@company.com |
+----+-------+-------+---------+-----------------------+
2 rows in set (0.00 sec)

   插入一條id為6的記錄,它排在了id為5的記錄之后。再插入兩條記錄進(jìn)行觀察:

mysql> insert into members values (8, 'Chen', 'Zhang', '8888888', 'chenzhang@com
pany.com');
Query OK, 1 row affected (0.43 sec)

mysql> insert into members values (7, 'Yifei', 'Yin', '7777777', 'yfyin@company.
com');
Query OK, 1 row affected (0.42 sec)

mysql> select * from members limit 5,6;
+----+-------+-------+---------+-----------------------+
| id | fname | lname | tel     | email                 |
+----+-------+-------+---------+-----------------------+
|  8 | Chen  | Zhang | 8888888 | chenzhang@company.com |
+----+-------+-------+---------+-----------------------+
1 row in set (0.00 sec)

mysql> select * from members limit 4,6;
+----+-------+-------+---------+-----------------------+
| id | fname | lname | tel     | email                 |
+----+-------+-------+---------+-----------------------+
|  7 | Yifei | Yin   | 7777777 | yfyin@company.com     |
|  8 | Chen  | Zhang | 8888888 | chenzhang@company.com |
+----+-------+-------+---------+-----------------------+
2 rows in set (0.01 sec)

mysql> select * from members limit 3,6;
+----+-------+-------+---------+-----------------------+
| id | fname | lname | tel     | email                 |
+----+-------+-------+---------+-----------------------+
|  6 | Chao  | Zhang | 6666666 | chaozhang@company.com |
|  7 | Yifei | Yin   | 7777777 | yfyin@company.com     |
|  8 | Chen  | Zhang | 8888888 | chenzhang@company.com |
+----+-------+-------+---------+-----------------------+
3 rows in set (0.00 sec)

   可以看到,不管是重新插入刪除掉的記錄的也好,讓id值較大的記錄比id值較小的記錄先插入也好,行號(hào)的大小順序好像都是由id字段的大小順序決定的。而“select * from members;”的結(jié)果則體現(xiàn)了行號(hào)的大小順序。

mysql> select * from members;
+----+-------+-------+---------+-----------------------+
| id | fname | lname | tel     | email                 |
+----+-------+-------+---------+-----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com    |
|  2 | Feng  | Song  | 7654321 | fengsong@company.com  |
|  5 | Chen  | Chu   | NULL    | chenchu@company.com   |
|  6 | Chao  | Zhang | 6666666 | chaozhang@company.com |
|  7 | Yifei | Yin   | 7777777 | yfyin@company.com     |
|  8 | Chen  | Zhang | 8888888 | chenzhang@company.com |
+----+-------+-------+---------+-----------------------+
6 rows in set (0.00 sec)

   為了確定這種猜測(cè),再做一組實(shí)驗(yàn):

mysql> create table members_temp
   -> (
   -> id int(3),
   -> fname varchar(20),
   -> lname varchar(20),
   -> tel varchar(15),
   -> email varchar(50)
   -> );
Query OK, 0 rows affected (0.48 sec)

mysql> insert into members_temp (id, fname, lname) values (1, 'Yue', 'Gao');
Query OK, 1 row affected (0.43 sec)

mysql> insert into members_temp (id, fname, lname) values (2, 'Feng', 'Song');
Query OK, 1 row affected (0.03 sec)

mysql> insert into members_temp (id, fname, lname) values (5, 'Chen', 'Chu');
Query OK, 1 row affected (0.43 sec)

mysql> select * from members_temp;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    1 | Yue   | Gao   | NULL | NULL  |
|    2 | Feng  | Song  | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
+------+-------+-------+------+-------+
3 rows in set (0.00 sec)

mysql> select * from members_temp limit 2,3;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    5 | Chen  | Chu   | NULL | NULL  |
+------+-------+-------+------+-------+
1 row in set (0.01 sec)

mysql> select * from members_temp limit 1,3;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    2 | Feng  | Song  | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
+------+-------+-------+------+-------+
2 rows in set (0.00 sec)

mysql> select * from members_temp limit 0,3;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    1 | Yue   | Gao   | NULL | NULL  |
|    2 | Feng  | Song  | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
+------+-------+-------+------+-------+
3 rows in set (0.00 sec)

mysql> insert into members_temp (id, fname, lname) values (3, 'Yifei', 'Yin');
Query OK, 1 row affected (0.42 sec)

mysql> select * from members_temp;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    1 | Yue   | Gao   | NULL | NULL  |
|    2 | Feng  | Song  | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
|    3 | Yifei | Yin   | NULL | NULL  |
+------+-------+-------+------+-------+
4 rows in set (0.00 sec)

mysql> select * from members_temp limit 3,4;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    3 | Yifei | Yin   | NULL | NULL  |
+------+-------+-------+------+-------+
1 row in set (0.00 sec)

mysql> select * from members_temp limit 2,4;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    5 | Chen  | Chu   | NULL | NULL  |
|    3 | Yifei | Yin   | NULL | NULL  |
+------+-------+-------+------+-------+
2 rows in set (0.00 sec)

mysql> delete from members_temp where id = 2;
Query OK, 1 row affected (0.42 sec)

mysql> select * from members_temp;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    1 | Yue   | Gao   | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
|    3 | Yifei | Yin   | NULL | NULL  |
+------+-------+-------+------+-------+
3 rows in set (0.00 sec)

mysql> insert into members_temp (id, fname, lname) values (2, 'Feng', 'Song');
Query OK, 1 row affected (0.03 sec)

mysql> select * from members_temp;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    1 | Yue   | Gao   | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
|    3 | Yifei | Yin   | NULL | NULL  |
|    2 | Feng  | Song  | NULL | NULL  |
+------+-------+-------+------+-------+
4 rows in set (0.00 sec)

   到這里可以看到,新創(chuàng)建的表沒(méi)有索引,也沒(méi)有主鍵,不管是讓id值較大的記錄比id值較小的記錄先插入也好,重新插入刪除掉的記錄的也好,行號(hào)都是由記錄插入的先后順序決定的。

mysql> create index id_idx on members_temp (id);
Query OK, 4 rows affected (0.71 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from members_temp;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    1 | Yue   | Gao   | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
|    3 | Yifei | Yin   | NULL | NULL  |
|    2 | Feng  | Song  | NULL | NULL  |
+------+-------+-------+------+-------+
4 rows in set (0.00 sec)

mysql> delete from members_temp where id = 5;
Query OK, 1 row affected (0.03 sec)

mysql> insert into members_temp (id, fname, lname) values (5, 'Chen', 'Chu');
Query OK, 1 row affected (0.04 sec)

mysql> select * from members_temp;
+------+-------+-------+------+-------+
| id   | fname | lname | tel  | email |
+------+-------+-------+------+-------+
|    1 | Yue   | Gao   | NULL | NULL  |
|    3 | Yifei | Yin   | NULL | NULL  |
|    2 | Feng  | Song  | NULL | NULL  |
|    5 | Chen  | Chu   | NULL | NULL  |
+------+-------+-------+------+-------+
4 rows in set (0.00 sec)

   在id列上創(chuàng)建索引,依然如此。

mysql> alter table members_temp add constraint primary key (id);
Query OK, 4 rows affected (0.64 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from members_temp;
+----+-------+-------+------+-------+
| id | fname | lname | tel  | email |
+----+-------+-------+------+-------+
|  1 | Yue   | Gao   | NULL | NULL  |
|  2 | Feng  | Song  | NULL | NULL  |
|  3 | Yifei | Yin   | NULL | NULL  |
|  5 | Chen  | Chu   | NULL | NULL  |
+----+-------+-------+------+-------+
4 rows in set (0.01 sec)

mysql> delete from members_temp where id = 2;
Query OK, 1 row affected (0.45 sec)

mysql> insert into members_temp (id, fname, lname) values (2, 'Feng', 'Song');
Query OK, 1 row affected (0.03 sec)

mysql> select * from members_temp;
+----+-------+-------+------+-------+
| id | fname | lname | tel  | email |
+----+-------+-------+------+-------+
|  1 | Yue   | Gao   | NULL | NULL  |
|  2 | Feng  | Song  | NULL | NULL  |
|  3 | Yifei | Yin   | NULL | NULL  |
|  5 | Chen  | Chu   | NULL | NULL  |
+----+-------+-------+------+-------+
4 rows in set (0.00 sec)

mysql> select * from members_temp limit 3,4;
+----+-------+-------+------+-------+
| id | fname | lname | tel  | email |
+----+-------+-------+------+-------+
|  5 | Chen  | Chu   | NULL | NULL  |
+----+-------+-------+------+-------+
1 row in set (0.00 sec)

mysql> select * from members_temp limit 2,4;
+----+-------+-------+------+-------+
| id | fname | lname | tel  | email |
+----+-------+-------+------+-------+
|  3 | Yifei | Yin   | NULL | NULL  |
|  5 | Chen  | Chu   | NULL | NULL  |
+----+-------+-------+------+-------+
2 rows in set (0.00 sec)

mysql> select * from members_temp limit 1,4;
+----+-------+-------+------+-------+
| id | fname | lname | tel  | email |
+----+-------+-------+------+-------+
|  2 | Feng  | Song  | NULL | NULL  |
|  3 | Yifei | Yin   | NULL | NULL  |
|  5 | Chen  | Chu   | NULL | NULL  |
+----+-------+-------+------+-------+
3 rows in set (0.00 sec)

mysql> select * from members_temp limit 0,4;
+----+-------+-------+------+-------+
| id | fname | lname | tel  | email |
+----+-------+-------+------+-------+
|  1 | Yue   | Gao   | NULL | NULL  |
|  2 | Feng  | Song  | NULL | NULL  |
|  3 | Yifei | Yin   | NULL | NULL  |
|  5 | Chen  | Chu   | NULL | NULL  |
+----+-------+-------+------+-------+
4 rows in set (0.00 sec)

mysql> select * from members;
+----+-------+-------+---------+-----------------------+
| id | fname | lname | tel     | email                 |
+----+-------+-------+---------+-----------------------+
|  1 | Yue   | Gao   | 1234567 | yuegao@company.com    |
|  2 | Feng  | Song  | 7654321 | fengsong@company.com  |
|  5 | Chen  | Chu   | NULL    | chenchu@company.com   |
|  6 | Chao  | Zhang | 6666666 | chaozhang@company.com |
|  7 | Yifei | Yin   | 7777777 | yfyin@company.com     |
|  8 | Chen  | Zhang | 8888888 | chenzhang@company.com |
+----+-------+-------+---------+-----------------------+
6 rows in set (0.00 sec)

   在id列上添加主鍵后,行號(hào)變?yōu)橛蒳d列的大小順序決定,這就證明了之前的猜想。

感謝各位的閱讀,以上就是“怎么修改MySQL root用戶口令”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)怎么修改MySQL root用戶口令這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI