“数据库类课程资源建设( MySQL 数据库应用与设计)”教学方向资源建设
1
【任务 6-4】在命令行使用 Insert 语句添加 MySQL 的
用户
【任务描述】
使用 Insert 语句添加一个新用户,用户名为 Lucky,密码是 123456,主机为本机。
【任务实施】
在命令行提示符后输入以下命令创建用户 Lucky:
Insert Into mysql.user(Host , User , Authentication_string )
Values (''localhost'', ''Lucky'', Password(''123456'')) ;
该语句的执行结果如下:
mysql> Insert Into mysql.user(Host , User , Authentication_string )
Values (''localhost'', ''Lucky'', Password(''123456'')) ;
ERROR 1364 (HY000): Field ''ssl_cipher'' doesn''t have a default value
语句执行失败,使用“ Show Warnings ;”语句查看相关错误提示信息如图 6-13 所示。
图 6-13 使用“ Show Warnings ;”语句查看相关错 误提示信息的结果
将 Insert 语句进一步完善如下:
Insert Into mysql.user(Host , User , Authentication_string,
ssl_cipher,x509_issuer,x509_subject )
Values (''localhost'', ''Lucky'', Password(''123456''), '''', '''', '''' ) ;
在 Insert 语句中将 ssl_cipher、 x509_issuer、 x509_subject 这 3 个字段的默认值设置为
空。该语句的执行结果如下:
Query OK, 1 row affected, 1 warning (0.01 sec)
“数据库类课程资源建设( MySQL 数据库应用与设计)”教学方向资源建设
2
结果显示使用 Insert 语句添加新成功。
|
|