1. 程式人生 > >mysql建立使用者及常見錯誤

mysql建立使用者及常見錯誤

(1)指令碼:CREATE USER 'username'@'host' [IDENTIFIED BY 'PASSWORD'] 

               例:create user 'user02'@'localhost' identified by 'yx';

               如果報錯:

   mysql> create user '3110006389'@'localhost' identified by '6389';

                    Query OK, 0 rows affected (0.00 sec)

                    mysql> grant all on *.* to '3110006389'@'localhost';

ERROR 1133 (42000): Can't find any matching row in the user table

                   問題出現在,因為我們在create user時修改了mysql.user表之後,

                   沒有使用FLUSH PRIVILEGES命令來更新許可權表(grant tables).

                    所以在執行grant on時執行flush privileges就沒有這個錯誤了。(2) insert into user(host,user,password) values("localhost","user02",password("yx"));


               如果報錯:

               如果報錯:ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

               原因:在我的配置檔案my.ini中有這樣一條語句

      sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

               指定了嚴格模式,為了安全,嚴格模式禁止通過insert 這種形式直接修改mysql庫中的user表進行新增新使用者

               解決辦法:開啟my.ini,查詢 

      sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

      修改為

      sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

      然後重啟MYSQL