ホームページ  >  記事  >  バックエンド開発  >  Linux PHP に mysql に接続するための十分な権限がない場合の対処方法

Linux PHP に mysql に接続するための十分な権限がない場合の対処方法

藏色散人
藏色散人オリジナル
2021-10-26 10:01:192425ブラウズ

Linux PHP には、MySQL に接続するための権限が不十分です: 1. クエリ、挿入、およびその他の権限を、grant コマンドを使用して通常のデータ ユーザーに付与します。2. テーブルとインデックスを作成する権限を、grant を通じてデータベース開発者に付与します。 。

Linux PHP に mysql に接続するための十分な権限がない場合の対処方法

この記事の動作環境: linux5.9.8 システム、PHP バージョン 7.1、DELL G3 コンピューター

Linux php に mysql に接続するための十分な権限がない場合はどうすればよいですか?

Linux php には、mysql に接続するための十分な権限がありません。Mysql の詳細な権限分割:

mysql では、select、insert、更新、削除など。1 つ以上の権限は主に Grant コマンドを使用します。使用形式は次のとおりです:

grant 权限 on 数据库对象 to 用户

1. 通常のデータ ユーザーに、すべてのテーブルのクエリ、挿入、更新、および削除を行う権限を付与します。データベース内のデータ

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@’%’

2. データベース開発者に、テーブル、インデックス、ビュー、ストアド プロシージャ、および関数を作成する権限を与えます。 。 。 Waiting for Permissions

grant 创建、修改、删除 mysql 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; - now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; - now, you can drop a procedure
grant execute on testdb.* to developer@’192.168.0.%’;

3. 特定の mysql データベースを管理するための通常の DBA 権限を付与します

grant all privileges on testdb to dba@’localhost’

このうち、キーワード「privileges」は省略可能です。

4. 上級 dba の付与は、mysql のすべてのデータベースの権限を管理します

grant all on *.* to dba@’localhost’

5. Mysql の付与権限は複数のレベルで使用できます

1. 付与は、次の段階で機能します。 mysql サーバー全体:

grant select on *.* to dba@localhost; - dba 可以查询 mysql 中所有数据库中的表。
grant all on *.* to dba@localhost; - dba 可以管理 mysql 中的所有数据库

2. 付与は単一のデータベースに作用します:

grant select on testdb.* to dba@localhost; - dba 可以查询 testdb 中的表。

3. 付与は単一のデータ テーブルに作用します:

grant select, insert, update, delete on testdb.orders to dba@localhost;

4. 付与は次の対象に作用しますテーブル内の列:

grant select(id, se, rank) on testdb.apache_log to dba@localhost;

5. ストアド プロシージャと関数に対する権限の付与:

grant execute on procedure testdb.pr_add to ’dba’@’localhost’
grant execute on function testdb.fn_add to ’dba’@’localhost’

6. mysql ユーザー権限の表示

現在のユーザー (自分の) 権限の表示:

show grants;

他の mysql ユーザー権限を表示:

show grants for dba@localhost;

7. mysql ユーザー権限に付与されている権限を取り消します

revoke には付与する同様の構文があります。キーワードを追加します 「to」を「from」に置き換えるだけです:

grant all on *.* to dba@localhost;
revoke all on *.* from dba@localhost;

8. mysql のユーザー権限の付与と取り消しに関する注意事項

1. 付与後、ユーザー権限を取り消します。ユーザーは再接続のみ可能です。 mysql データベースにアクセスすると、権限が有効になります。

2. 承認されたユーザーがこれらのアクセス許可を他のユーザーに付与したい場合は、「付与オプション」オプションが必要です。

grant select on testdb.* to dba@localhost with grant option;

この機能は通常は使用されません。実際には、データベース権限は DBA によって均一に管理されるのが最適です。

注: 権限を変更した後は、サービスを更新するか、サービスを再起動する必要があります。

推奨される学習: 「

PHP ビデオ チュートリアル

以上がLinux PHP に mysql に接続するための十分な権限がない場合の対処方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。