이 문서의 예제는 MySQL 5.0 이상에서 실행됩니다.
MySQL 사용자 권한을 부여하는 간단한 명령 형식은 다음과 같이 요약할 수 있습니다.
grant 权限 on 数据库对象 to 用户
관련 학습 권장 사항: mysql 비디오 튜토리얼
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. 데이터베이스 개발자에게 테이블, 인덱스, 뷰, 저장 프로시저 및 함수를 만들 수 있는 권한을 부여합니다. . . 및 기타 권한.
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.%';
MySQL 임시 테이블 운영 권한을 부여합니다.
grant create temporary tables on testdb.* to developer@'192.168.0.%';
MySQL 인덱스 운영 권한을 부여하세요.
grant index on testdb.* to developer@'192.168.0.%';
MySQL 뷰를 조작하고 소스 코드를 볼 수 있는 권한을 부여하세요.
grant create view on testdb.* to developer@'192.168.0.%'; grant show view on testdb.* to developer@'192.168.0.%';
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. 일반 DBA에게 MySQL 데이터베이스 관리 권한을 부여합니다.
grant all privileges on testdb to dba@'localhost'
이중 '특권'이라는 키워드는 생략 가능합니다.
4. 선임 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는 단일 데이터베이스에서 작동합니다.
grant select on testdb.* to dba@localhost; -- dba 可以查询 testdb 中的表。
3. Grant는 단일 데이터 테이블에서 작동합니다.
grant select, insert, update, delete on testdb.orders to dba@localhost;
여기에서는 한 명의 사용자가 여러 테이블에 대해 권한을 부여받습니다. , 위의 문은 여러 번 실행될 수 있습니다. 예:
grant select(user_id,username) on smp.users to mo_user@'%' identified by '123345'; grant select on smp.mo_sms to mo_user@'%' identified by '123345';
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. 현재 사용자 보기(자신의) 권한 :
show grants;다른 MySQL 사용자 권한 보기:
show grants for dba@localhost;
7. MySQL 사용자 권한에 부여된 권한을 취소합니다.
revoke에는 grant와 비슷한 구문이 있습니다. "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가 균일하게 관리하는 것이 가장 좋습니다.
위 내용은 MySQL에서 Grant 명령을 사용하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

mysqlStringTypESmpactStorageAndperformanceAsfollows : 1) charisfixed, adlaysamestoragespace.

mysqlstringtypesincludevarchar, text, char, enum, and set.1) varcharisversatileforvariable-lengthstringsupciedlimit.2) textisidealforlargetextStorage whithoudfinedlength.3) charisfixed, witableforconsistentDatalikecodes.4)

mysqloffersvariousstringdatatatypes : 1) charfixed-lengthstrings, 2) varcharforvariable-lengthtext, 3) binaryandvarbinaryforbinarydata, 4) blobandtextforlargedata 및 5) enumandsetforcontrolledInput.achtolledinput.CheachorciCificusessandperististicatististicatististics

ToadDuserSinMySqleFeffectially, 다음에 따르면, 다음 사항을 따르십시오

toaddanewuser와 함께 complexpermissionsinmysql, followthesesteps : 1) createShereuser'NewUser '@'localhost'Identifiedby'pa ssword ';. 2) grantreadaccesstoalltablesin'mydatabase'withgrantselectonmydatabase.to'newuser'@'localhost';. 3) GrantWriteAccessto '

MySQL의 문자열 데이터 유형에는 char, varchar, binary, varbinary, blob 및 텍스트가 포함됩니다. 콜라이트는 문자열의 비교와 분류를 결정합니다. 1. 차량은 고정 길이 스트링에 적합하고 Varchar는 가변 길이 스트링에 적합합니다. 2. 이진 및 바이너리는 이진 데이터에 사용되며 Blob 및 텍스트는 큰 객체 데이터에 사용됩니다. 3. UTF8MB4_UNICODE_CI와 같은 정렬 규칙은 상류 및 소문자를 무시하며 사용자 이름에 적합합니다. UTF8MB4_BIN은 사례에 민감하며 정확한 비교가 필요한 필드에 적합합니다.

가장 좋은 mysqlvarchar 열 길이 선택은 데이터 분석을 기반으로하고, 향후 성장을 고려하고, 성능 영향을 평가하고, 문자 세트 요구 사항을 기반으로해야합니다. 1) 일반적인 길이를 결정하기 위해 데이터를 분석합니다. 2) 미래 확장 공간을 예약하십시오. 3) 성능에 대한 큰 길이의 영향에주의를 기울이십시오. 4) 문자 세트가 스토리지에 미치는 영향을 고려하십시오. 이러한 단계를 통해 데이터베이스의 효율성과 확장 성을 최적화 할 수 있습니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

드림위버 CS6
시각적 웹 개발 도구

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.