>  기사  >  백엔드 개발  >  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은 선택, 삽입, 업데이트, 삭제 등 하나 이상의 권한을 주로 사용자에게 부여할 수 있습니다. 명령, 사용법 형식은

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. 데이터베이스 개발자에게 권한을 부여하고 테이블, 인덱스, 뷰, 저장 프로시저, 함수를 생성합니다. . . etc. 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. Grant 수석 DBA는 mysql

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

5의 모든 데이터베이스를 관리할 수 있는 권한을 가집니다. MySQL 부여 권한은 여러 수준에서 적용될 수 있습니다

1. Grant는 전체 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는 단일 데이터 테이블에서 작동합니다:

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

4. Grant는 테이블의 열에서 작동합니다:

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

5. Grant는 저장 프로시저 및 함수에서 작동합니다:

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 option" 옵션이 필요합니다.

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

이 기능은 일반적으로 사용되지 않습니다. 실제로 데이터베이스 권한은 DBA가 균일하게 관리하는 것이 가장 좋습니다.

참고: 권한을 수정한 후 서비스를 새로 고치거나 서비스를 다시 시작해야 합니다

권장 학습: "PHP 비디오 튜토리얼"

위 내용은 Linux PHP에 mysql에 연결할 수 있는 권한이 충분하지 않은 경우 수행할 작업의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.