[MySQL FAQ]系列 -- 账号密码包含反斜线时怎么办
生活随笔
收集整理的這篇文章主要介紹了
[MySQL FAQ]系列 -- 账号密码包含反斜线时怎么办
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
作/譯者:葉金榮(Email: ),來源:http://imysql.cn,轉載請注明作/譯者和出處,并且不能用于商業用途,違者必究。 問: 如果密碼中包含反斜線,該如何處理呢?
答: 在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個反斜線。 本文出自 “MySQL中文網”博客 http://www.imysql.cn/
答: 在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個反斜線。 本文出自 “MySQL中文網”博客 http://www.imysql.cn/
總結
以上是生活随笔為你收集整理的[MySQL FAQ]系列 -- 账号密码包含反斜线时怎么办的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Delphi 7 以来的语法等变化
- 下一篇: 路由器用PPP0E上网