Mysqlでの新規ユーザーおよびライセンスの共有方法
プロジェクト開発の過程で自分のデータベースを他の人に開放する必要があるかもしれませんが、安全のために自分のサーバー内の他のデータベースを同時に開放することはできません.では、ユーザーを新規作成し、特定のデータベース権限を開くことができます.
テスト環境:Centos 6.3とMysql 5.3
一、新規ユーザー
これにより、cplusplusという名前のパスワード:cplusplusが作成されます.私のユーザー.
二、ログインテスト
?
1
2
3
4
三、ユーザーの授権
?
1
2
3
4
5
6
7
8
9
10
四、一部授権
?
1
2
3
五、ユーザーの削除
?
1
2
3
4
六、データベースの削除
?
1
七、パスワードの修正
?
1
2
3
4
ネットユーザーの経験を共有します.
1.新規ユーザー
ユーザーroot権限mysqlにログインし、データベースと同じ名前のユーザーを新規作成します.
?
1
システム権限テーブルのリフレッシュ
?
1
もし新聞が間違っていたら
?
1
MySQLプロファイルlinuxシステムを/etc/myに変更cnf、windowsシステムはmyです.ini
?
1
次のように変更
?
1
MySQLサービスの再起動
2.ユーザーに権限を与える
?
1
2
テスト環境:Centos 6.3とMysql 5.3
一、新規ユーザー
// MYSQL
@>mysql -u root -p
@>
//
mysql> insert into mysql.user(Host,User,Password) values("localhost","cplusplus",password("cplusplus.me"));
//
mysql>flush privileges;
これにより、cplusplusという名前のパスワード:cplusplusが作成されます.私のユーザー.
二、ログインテスト
?
1
2
3
4
mysql>exit;
@>mysql -u cplusplus -p
@>
mysql>
三、ユーザーの授権
?
1
2
3
4
5
6
7
8
9
10
// MYSQL
@>mysql -u root -p
@>
// (cplusplusDB)
mysql>
create
database
cplusplusDB;
// cplusplus cplusplusDB 。
>
grant
all
privileges
on
cplusplusDB.*
to
cplusplus@localhost identified
by
'cplusplus.me'
;
//
mysql>flush
privileges
;
mysql>
四、一部授権
?
1
2
3
mysql>
grant
select
,
update
on
cplusplusDB.*
to
cplusplus@localhost identified
by
'cplusplus.me'
;
// 。
mysql>flush
privileges
;
五、ユーザーの削除
?
1
2
3
4
@>mysql -u root -p
@>
mysql>
DELETE
FROM
user
WHERE
User
=
"cplusplus"
and
Host=
"localhost"
;
mysql>flush
privileges
;
六、データベースの削除
?
1
mysql>
drop
database
cplusplusDB;
七、パスワードの修正
?
1
2
3
4
@>mysql -u root -p
@>
mysql>
update
mysql.
user
set
password
=
password
(
' '
)
where
User
=
"cplusplus"
and
Host=
"localhost"
;
mysql>flush
privileges
;
ネットユーザーの経験を共有します.
1.新規ユーザー
ユーザーroot権限mysqlにログインし、データベースと同じ名前のユーザーを新規作成します.
?
1
mysql>
INSERT
INTO
mysql.
user
(Host,
User
,
Password
)
VALUES
(
'localhost'
,
'sun'
,
password
(
'sun123456'
));
システム権限テーブルのリフレッシュ
?
1
mysql> FLUSH
PRIVILEGES
;
もし新聞が間違っていたら
?
1
#1364 – Field ‘ssl_cipher
' doesn'
t have a
default
value
MySQLプロファイルlinuxシステムを/etc/myに変更cnf、windowsシステムはmyです.ini
?
1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
次のように変更
?
1
sql_mode=NO_ENGINE_SUBSTITUTION
MySQLサービスの再起動
2.ユーザーに権限を与える
?
1
2
mysql>
GRANT
ALL
ON
sun.*
to
sun@localhost identified
BY
'sun123456'
;
mysql> FLUSH
PRIVILEGES
;