用mariadb也有一段時間了,經常使用命令和語法,基本沒變。比較複雜一點的,例如replication,也沒有發現根mysql有什麼不一樣的地方。php
不過,今天真發現有不一樣的地方了,mariadb的權限管理根mysql不同,mysql能夠建立一個根root帳戶同等權限的帳戶,可是mariadb就不行了,寫法上也所不一樣。html
1,mariadb grant受權報錯
MariaDB [(none)]> grant all privileges on *.* TO tank@'192.168.%' IDENTIFIED BY 'test';
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) mysql
相同的命令在mysql下,執行是沒有任何問題的。
一開始覺得是mariadb的root帳號和密碼有問題,檢查後沒問題。sql
2,mariadb與mysql root權限不一樣spa
查看了一下,root帳戶所擁有的權限,mariadb和mysql是不同的。
MariaDB [(none)]> show grants\G;
*************************** 1. row ***************************
Grants for root@localhost: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'root'@'localhost' WITH GRANT OPTION
1 row in set (0.00 sec)
ERROR: No query specified
mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec) .net
3,mariadb與mysql grant語法不一樣htm
具體的講法以,請參考:https://mariadb.com/kb/en/mariadb/grant/
MariaDB [(none)]> grant all on test.* TO tank@'192.168.%' IDENTIFIED BY 'test';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant select on *.* TO tank@'192.168.%' IDENTIFIED BY 'test';
Query OK, 0 rows affected (0.00 sec) ci
第一條命令,將test庫的全部權限都給tank
第二條命令,將全部庫和表的select權限給tank
注意:all不能和*.*一塊兒使用的,否則就報錯了。get