mysqllinux許可權
hi 樓主,在資料庫中創建包含很多,視圖,索引,臨時表的創建許可權都能分開賦予,你可以執行 show privileges 來查看許可權參數,我這邊就以創建表為例,只包含查詢表功能,其他修改,刪除,備份沒有許可權;以下是步驟:
1,create user 'tom'@'%' identified by '123456';---創建用戶,無許可權;
2, grant create,select on wangxh2.* to tom;-----把wangxh2庫的所有表的創建和查詢賦予tom
3,flush privileges;-----刷新許可權表才能起效
接下來是測試:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
| wangxh2 |
+--------------------+
3 rows in set (0.06 sec)
mysql> use wangxh2
Database changed
mysql> show tables;
+-------------------+
| Tables_in_wangxh2 |
+-------------------+
| test |
+-------------------+
1 row in set (0.00 sec)
mysql> drop test;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test' at line 1
mysql> drop table test;
ERROR 1142 (42000): DROP command denied to user 'tom'@'localhost' for table 'test'
mysql> select count(*) from test;
+----------+
| count(*) |
+----------+
| 33554432 |
+----------+
1 row in set (0.01 sec)
mysql> insert into test values(1);
ERROR 1142 (42000): INSERT command denied to user 'tom'@'localhost' for table 'test'
mysql> delete from test;
ERROR 1142 (42000): DELETE command denied to user 'tom'@'localhost' for table 'test'
mysql> update test set id=1;
ERROR 1142 (42000): UPDATE command denied to user 'tom'@'localhost' for table 'test'
mysql> create table test1 (id int);
Query OK, 0 rows affected (0.02 sec)
mysql> insert into test1 values(1);
ERROR 1142 (42000): INSERT command denied to user 'tom'@'localhost' for table 'test1'
[mysql@localhost ~]$ mysqlmp -u tom -paidengshan wangxh2 >/home/mysql/aa.sql
mysqlmp: Got error: 1044: Access denied for user 'tom'@'%' to database 'wangxh2' when using LOCK TABLES
[mysql@localhost ~]$
-----------------------------------------------------------------------------------------
以上測試發現,tom對wangxh2有建表,查詢表的許可權,但是修改,刪除,新增,備份都沒有許可權,達到你的需求了
『貳』 linux用命令怎麼修改mysql用戶的許可權
mysql更改用戶許可權
This entry was posted by admin Monday, 26 April, 2010
1.「grant all on *.* to root@』%』 identified by 『yourpassword』;」——這個還可以順帶設置密碼。
2.「flush privileges; 」——刷新一下,讓許可權生效。
mysql的一些其他的管理,可以用mysqladmin命令。可以用來設置密碼什麼的。
grant方面的詳細信息可以看我下面的轉載:
本文實例,運行於 MySQL 5.0 及以上版本。
MySQL 賦予用戶許可權命令的簡單格式可概括為:
grant 許可權 on 資料庫對象 to 用戶
一、grant 普通數據用戶,查詢、插入、更新、刪除 資料庫中所有表數據的權利。
grant select on testdb.* to common_user@』%』
grant insert on testdb.* to common_user@』%』
grant update on testdb.* to common_user@』%』
grant delete on testdb.* to common_user@』%』
或者,用一條 MySQL 命令來替代:
grant select, insert, update, delete on testdb.* to common_user@』%』
『叄』 windows和Linux下的mysql授權表設置攻略
在Windows中,當mysql安裝完成之後不需要創建數據目錄和授權表。在數據目錄下的MySQL資料庫中存在一套預初始化的'賬戶的授權表。不要運行Unix中使用的mysql_install_db腳本。
在Unix上安裝MySQL後,需要初始化授權表、啟動伺服器,並確保伺服器工作正常。並為授權表中的賬戶指定密碼。
在Unix中,由mysql_install_db設置授權表。
如果系統為安裝好的CentOS5,則只需要運行
# mysql_install_db --user=mysql --datadir=/var/lib/mysql_ndbd/
一定要確保由mysql登錄賬戶擁有資料庫目錄和文件,以便在以後運行伺服器具有讀、寫訪問許可權。
當然,也可以以
mysqld_safe --user=mysql --skip-grant-tables & 跳過授權表來登錄,登錄進去重新賦許可權,同時更新許可權表:flush privileges
『肆』 修改linux中mysql上存在的用戶許可權
一、KILL掉系統里的MySQL進程
php">killall-TERMmysqld
二、用以下命令啟動MySQL,以不檢查許可權的方式啟動
safe_mysqld–skip-grant-tables&
三、用空密碼方式使用root用戶登錄 MySQL
mysql-uroot
四、修改root用戶的密碼
mysql>updatemysql.usersetpassword=PASSWORD(『新密碼』)whereUser=』root』;
mysql>flushprivileges;
mysql>quit
『伍』 Linux 如何開啟MySQL遠程訪問許可權 允許遠程連接
1。 改表法。可能是你的帳號不允許從遠程登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 "mysql" 資料庫里的 "user" 表裡的 "host" 項,從"localhost"改稱"%"
mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = '%' where user = 'root';mysql>select host, user from user;
2. 授權法。例如,你想myuser使用mypassword從任何主機連接到mysql伺服器的話。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允許用戶myuser從ip為192.168.1.3的主機連接到mysql伺服器,並使用mypassword作為密碼
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
我的mysql.user里root用戶的host果然是localhost,先用改表法給localhost改成「%」,還是不行,仍然報1130的錯 誤,又按「從任何主機連接到mysql伺服器」方法授權,還是報一樣的錯,最後給自己的ip授權之後,終於登錄上了。。。。
『陸』 查看linux下mysql有沒有遠程訪問許可權
1、root用戶登錄到mysql資料庫 代碼示例: /usr/local/mysql/bin/mysql -u root -p (輸入密碼進入mysql) 2、進入mysql,輸入: 代碼示例: use mysql; 3、查看user表的情況 代碼示例: SELECT Host,User FROM user; //指明主機名稱,
『柒』 Linux下mysql允許遠程連接怎麼設置
這個問題分兩部分:
1、需要系統本身開通資料庫對應的埠,mysql應該是
3306(或者直接關閉防火牆);
2、mysql開通連接許可權:
1:首次安裝的mysql應該是沒有密碼,使用:
mysql
-u
root
-p
回車,直接進入到mysql>頁面;
2:開通需要對外連接的帳號許可權:
1、update
mysql.user
set
password=PASSWORD('123456')
where
User='root';
(修改root密碼為123456)
2、grant
all
privileges
on
*.*
to
root@'%'
identified
by
'123456';
(授權root對外開放連接,密碼為123456)
3、flush
privileges;
(使以上操作生效)
4、quit
(退出)
然後在外部就可以嘗試連接
『捌』 Linux下禁止MySQL服務以管理員許可權的賬號運行命令
安全運行mysql服務。MySql應該使用非管理員賬號銷弊數運行,以普通賬戶安全運行虧首mysqld採用加固方法,Linux下禁止MySQL服務以管理員許可權的賬號運行命令,安全運行mysql服務,從而卜悄保證系統程序的正常運行。
『玖』 MYSQL提權(LINUX)
select @@global.secure_file_priv;
查看MySQL伺服器的文件讀寫許可權
如果是NULL就是完全禁止
udf提權用到的so文件(linux)在kali下默認集成,路徑為 /usr/share/sqlmap/udf/mysql/linux/64(32)
或者 searchsploit mysql udf
把對應的內容編譯出來
mysql創建函數命令
『拾』 Linux(fedora)下啟動MySQL,結果顯示:env: /etc/init.d/mysql:許可權不夠。 我已經將許可權切換到su了
Linu下啟動MySQL結果顯示:env: /etc/init.d/mysql: 是腳本執行的問題
解決辦法:依次執行下面的命令(執行失敗的話,檢查路徑是否正確):
cp /etc/init.d/mysql /etc/init.d/mysql.bak #拷貝/etc/init.d/mysql到/etc/init.d/mysql.bak文件
/etc/init.d/mysql.bak start #執行/etc/init.d/mysql.bak文件啟動mysql 成功!!!
rm /etc/init.d/mysql #刪除/etc/init.d/mysql文件
mv /etc/init.d/mysql.bak /etc/init.d/mysql #將/etc/init.d/mysql.bak重命名為/etc/init.d/mysql
5./etc/init.d/mysql start #執行/etc/init.d/mysql 啟動mysql 成功!