由以下示例得出,客户端连接MySQL时执行语句包括如下过程:
1.认证
是否可以登录MySQL服务端。
2.语法分析
判断执行语句是否合法,无语句错误。
3.权限分析
判断执行语句,是否有对目标的相关权限。
4.语义分析
判断是否存在相应的表和字段
5.优化执行
优化器优化SQL语句后,执行并返回结果。
1)mysql -utest -h227.0.0.1 -p -P3306 -perror
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'test'@'127.0.0.1' (using password: YES)
mysql> show grants;
+--------------------------------------------------------------------------+
| Grants for test@127.0.0.1 |
+--------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test'@'127.0.0.1' IDENTIFIED BY PASSWORD <secret> |
| GRANT SELECT ON `test`.* TO 'test'@'127.0.0.1' |
+--------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql>
mysql>
2)
mysql> select *** from test.t;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '** from test.t' at line 1
mysql>
3)
mysql> select * from a.t;
ERROR 1142 (42000): SELECT command denied to user 'test'@'127.0.0.1' for table 't'
mysql>
mysql>
4)
mysql> select * from test.t;
ERROR 1146 (42S02): Table 'test.t' doesn't exist
mysql>
mysql>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。