リレーショナル・データベースsql文
リレーショナル・データベースsql文
リレーショナル・データベースmysql SQL文データベース管理操作.
1.ユーザーの作成(create user):構文(syntax):
2.授権(grant):構文(syntax):
例(example):
アドレスが192.168.2.1101のshineユーザーにデータベースdemoテーブルuserにselect,insert,update,delete,create,drop権限を付与し、パスワード111111を使用する
アドレス192.168.2.1101のshineユーザにデータベースdemo上のすべてのテーブル上のすべての権限を付与し、パスワード111111を使用する.
shineユーザには、すべてのデータベース上のすべてのテーブル上のすべての権限が付与、パスワード111111が使用される.3.直接mysql.userテーブル挿入データ
4.システム権限の更新
5.mysqlユーザーパスワード方式の変更mysqladmin: を使用userテーブルを変更するユーザkey: set password文を使用してパスワードを変更:
6.ユーザーの削除とユーザー権限の取り消しユーザーとその権限の取り消し: ユーザー権限の取り消し: 表示権限ユーザー権限: 削除ユーザ:
9.
リレーショナル・データベースmysql SQL文データベース管理操作.
1.ユーザーの作成(create user):構文(syntax):
create user 'username'@'host' identified by 'password'
(example):
>create user 'shine'@'localhost' identified by '111111'; #
>create user 'shine'@'192.168.2.101' identified by '111111'; # ip :
>create user 'shine'@'%' identified by '111111'; # :
>create user 'shine'@'%' identified by ''; #
>create user 'shine'@'%'; #
>create user shine; #
2.授権(grant):構文(syntax):
grant privilege1 [,privilege [, privilege] ...] on databaseName.tableName to username@hostname/IP identified by 'password' privilege: select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process, file and so on fourteen privileges.
例(example):
>grant select, insert, update, delete, create, drop on demo.user to shine@192.168.2.101 identified by '111111';
アドレスが192.168.2.1101のshineユーザーにデータベースdemoテーブルuserにselect,insert,update,delete,create,drop権限を付与し、パスワード111111を使用する
>grant all privileges on demo.* to shine@192.168.2.101 identified by '111111';
アドレス192.168.2.1101のshineユーザにデータベースdemo上のすべてのテーブル上のすべての権限を付与し、パスワード111111を使用する.
>grant all privileges on *.* to shine@% identified by '111111'
shineユーザには、すべてのデータベース上のすべてのテーブル上のすべての権限が付与、パスワード111111が使用される.3.直接mysql.userテーブル挿入データ
>insert into user (host, user, password) values('%', 'shine', password('111111'));
4.システム権限の更新
>flush privileges;
5.mysqlユーザーパスワード方式の変更
syntax:
mysqladmin -u username -p oldpassword password newpassword
example:
mysqladmin -u shine -p 111111 password 123456
syntax:
update mysql.user set password=password('newpasswd') where User="username" and Host="IP";
example:
update user set password=password('111111') where user='shine';
flush privileges;
syntax:
set password for 'username'@'host' = password('newpassword');
set password = password('newpassword') # example: set password for 'shine'@'192.168.2.101'=password('111111');
6.ユーザーの削除とユーザー権限の取り消し
syntax:
drop user username;
example:
drop user shine@'%';
drop user shine@'localhost';
syntax:
revoke privilege on databasename.tablename from 'username'@'host';
example:
revoke select on *.* from 'shine'@'%';
revoke update on demo.user from 'shine'@'%';
revoke all on *.* from 'shine'@'%';
syntax:
show grants for 'username'@'hostname/IP';
example:
show grants for 'shine'@'192.168.2.101';
syntax:
delete from user where user = "username" and host="hostname/IP";
example:
delete from user where user = "shine" and host='192.168.2.101';