0
我想創建一個用戶在MySQL中擁有自己的數據庫的所有權限。MySQL創建表的問題 - 只讀錯誤
當我使用這個用戶創建一個表時,MySQL返回SQL服務器正在運行的只讀選項。
但是,當我更改爲*.*
上的所有權限的另一個現有用戶時,我可以創建表而不會出錯。
我想知道,只讀選項是全球性的還是什麼?
下面是使用MySQL的root我的MySQL命令:
mysql> create user 'demo'@'localhost' identified by 'demo'; mysql> create database demo; mysql> grant all privileges on demo.* to [email protected]; mysql> show grants for [email protected]; +-------------------------------------------------------------------------------------------------------------------+ | Grants for [email protected] | +-------------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'demo'@'localhost' IDENTIFIED BY PASSWORD '*demo-hashed*' | | GRANT ALL PRIVILEGES ON `demo`.* TO 'demo'@'localhost' | +-------------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)
然後我切換到用戶「演示」:
mysql> use demo; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> create table t(t1 int); ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement
於是我查了只讀選項,它似乎開啓。
然而,我嘗試使用*.*
特權的另一個用戶,我可以成功創建表。
的其他用戶授予設置:
mysql> show grants for [email protected]'%'; +-----------------------------------------------------------------------------------------------------------------+ | Grants for [email protected]% | +-----------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'demo2'@'%' IDENTIFIED BY PASSWORD '*demo2-hased*' | +-----------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
MySQL版本:
mysql> select version(); +------------------------+ | version() | +------------------------+ | 5.1.68.0 | +------------------------+ 1 row in set (0.00 sec)
順便說一句,在我設置read_only = 0
我可以使用demo
創建表。我只是不知道爲什麼demo2
可以創建表,而只讀打開。
謝謝!
你可以在兩個地方添加select current_user()。我發現的一個可能的原因是促使奴隸成爲主人。希望這不是你的情況 – georgecj11
嘗試重新啓動mysql – PravinS