我的编程空间,编程开发者的网络收藏夹
学习永远不晚

怎么修改MySQL root用户口令

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

怎么修改MySQL root用户口令

这篇文章主要讲解了“怎么修改MySQL root用户口令”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么修改MySQL root用户口令”吧!

1.一些基本概念

 1)MySQL体系结构由五个主子系统组成:查询引擎、存储管理器、缓冲管理器、事务管理器和恢复管理器。
 2)查询引擎包含三个相关联的部件:语法分析器、查询优化器和执行部件。
 3)除五个主子系统以外,MySQL体系结构还包括两个辅助部件:过程管理器和函数库。
 4)在MySQL中,事务的开始标记为一个BEGIN语句(与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.修改数据文件存放路径

   先关闭MySQL服务器:

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

   修改my.ini配置文件(默认放在 D:Program FilesMySQLMySQL Server 5.1 下)中的datadir参数:

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

   启动MySQL服务器,可以通过启动系统服务的方法。

4.一系列简单操作

 1)创建数据库,查看数据库,选择想要使用的数据库

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)创建表,查看表

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将要为这个字段自动生成一个数字(通过对前面的值增加1)。一个表只能有一个auto_increment字段,而且这个字段必须被定义为键(即字段上必须有索引,术语“键”和“索引”在MySQL中是等同的)。

   这时可以在数据文件的存放路径下看到新生成的文件:

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修饰符的作用,自动将新插入的记录id段的值设置为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的记录。也就是说,auto_increment修饰符不会重用那些曾经使用过的值。

 5)limit关键字

   使用limit关键字可以对结果集进行限制,它有两个参数,用逗号隔开,分别指定从哪行开始显示和显示多少行。如果只跟一个参数,则指定从结果集合的开头返回的行数。

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)

   可以看到行号是从0开始的,并且3条记录的行号是连续的。id为2的记录是删除后重新插入的,重新插入时id为5的记录已经存在,但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的记录之后。再插入两条记录进行观察:

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值较小的记录先插入也好,行号的大小顺序好像都是由id字段的大小顺序决定的。而“select * from members;”的结果则体现了行号的大小顺序。

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)

   为了确定这种猜测,再做一组实验:

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)

   到这里可以看到,新创建的表没有索引,也没有主键,不管是让id值较大的记录比id值较小的记录先插入也好,重新插入删除掉的记录的也好,行号都是由记录插入的先后顺序决定的。

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列上创建索引,依然如此。

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列上添加主键后,行号变为由id列的大小顺序决定,这就证明了之前的猜想。

感谢各位的阅读,以上就是“怎么修改MySQL root用户口令”的内容了,经过本文的学习后,相信大家对怎么修改MySQL root用户口令这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

怎么修改MySQL root用户口令

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

怎么在Linux下修改Mysql的用户root密码

本篇内容介绍了“怎么在Linux下修改Mysql的用户root密码”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!下面给大家分享下在Linux
2023-06-09

MySQL 如何修改root用户的密码

方法1:用SET PASSWORD命令mysql> set password for 用户名@localhost = password('新密码'); -- 举例 mysql> set password for root@localhost
2022-05-23

linux如何修改一个用户的口令 (只允许root执行)

通过sudo命令获取root权限,使用passwd命令更改特定用户的口令。另可使用usermod或chpasswd命令。注意仅允许root用户修改口令,并采用强口令。最佳实践包括定义口令策略、启用两因素验证、定期审核口令和使用密码管理器。
linux如何修改一个用户的口令 (只允许root执行)
2024-04-02

Kali Linux 2020.1怎么修改root用户密码

Kali Linux 2020.1怎么修改root用户密码,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。Kali Linux 2020.1修改root用户密码安装Kali
2023-06-05

Ubuntu中怎么修改 root帐户密码

这期内容当中小编将会给大家带来有关Ubuntu中怎么修改 root帐户密码,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。开启root帐号的方法:为了启用root 帐号(也就是设置一个口令)使用:sudo
2023-06-13

在Linux下如何修改Mysql的用户(root)的密码

下面给大家分享下在Linux下如何修改Mysql的用户(root)的密码,分两种情况:第一种当拥有原来的mysql的root密码,第二种情况忘记原来的mysql的root的密码。 修改的用户都以root为列。 一、拥有原来的mysql的ro
2022-06-04

ubuntu怎么更改用户权限为root

要将用户的权限更改为root,可以使用以下步骤:1. 以root用户身份登录系统。2. 打开终端或命令行界面。3. 输入以下命令来切换到要更改权限的用户:```sudo su - ```其中,``是要更改权限的用户的用户名。4. 输入以下命
2023-08-29

编程热搜

目录