开发学院数据库MySQL 账号密码包含反斜线时怎么办 阅读

账号密码包含反斜线时怎么办

 2009-10-19 00:00:00 来源:WEB开发网   
核心提示:问: 如果密码中包含反斜线,该如何处理呢?答: 在mysql中,账号密码包含反斜线时怎么办,反斜线"\"是有特殊意义的,用于转义,例如:(root:hostname:ThuOct1509:15:382009)[mysql]>grantusageon*.*toyejr@localhostiden

问: 如果密码中包含反斜线,该如何处理呢?

答: 在mysql中,反斜线"\"是有特殊意义的,用于转义,因此如果密码中包含"\",就需要特别注意。有一种一劳永逸的办法,就是在密码中不用反斜线,哈哈。另一种,那就是需要多加几个反斜线,例如:

(root:hostname:Thu Oct 15 09:15:38 2009)[mysql]> grant usage on *.* to yejr@localhost identified by 'ye\\\jr'; 
Query OK, 0 rows affected (0.02 sec) 
(root:imysql.cn:Thu Oct 15 09:16:22 2009)[mysql]> select password('ye\jr'); 
+-------------------------------------------+ 
| password('ye\jr')             | 
+-------------------------------------------+ 
| *9DB91006131E32B22135599033C6A9C196EC3C6B | 
+-------------------------------------------+ 
1 row in set (0.00 sec) 
(root:imysql.cn:Thu Oct 15 09:23:32 2009)[mysql]> select host,user,password from user where user='yejr';     
+-----------+------+-------------------------------------------+ 
| host   | user | password                 | 
+-----------+------+-------------------------------------------+ 
| localhost | yejr | *F06D79D5F57894772B64BF3164ABB714EBDBD3E2 | 
+-----------+------+-------------------------------------------+ 
1 row in set (0.01 sec) 
(root:imysql.cn:Thu Oct 15 09:16:28 2009)[mysql]> select password('ye\\\jr'); 
+-------------------------------------------+ 
| password('ye\\\jr')            | 
+-------------------------------------------+ 
| *F06D79D5F57894772B64BF3164ABB714EBDBD3E2 | 
+-------------------------------------------+ 
1 row in set (0.01 sec) 
[@tc_10.11.54.224_cnc ~]# mysql -uyejr -p'ye\jr' 
Logging to file '/home/mysql/query.log' 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 63 
Server version: 5.x.x-percona-highperf-x-log MySQL Percona High Performance Edition (GPL) 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
(yejr:imysql.cn:Thu Oct 15 09:24:58 2009)[(none)]> Bye 

从上面的例子可以看到,如果密码中有反斜线,就需要在它前面再加2个反斜线。

Tags:账号 密码 包含

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接