mysql 建立使用者並授權,設定允許遠端連線

2022-08-08 23:39:14 字數 813 閱讀 2752

一、建立使用者並授權

1、登入mysql

mysql -u root -q

2、建立資料庫

create database dbdata;//以建立dbdata為例

3、建立使用者

建立user01,只能本地訪問

create user user01@'localhost' identified by 'password';

建立user02,可以遠端訪問

create user user02@'%' identified by 'password'

4、修改使用者密碼

以user01為例:

set password for 'user01'@'localhost'=password('anotherpassword')

5、授權

授予user01管理dbdata的全部許可權

grant all privileges on dbdata.* to user01;

授予user02檢視許可權,並修改密碼

grant select on *.* to 'user02'@'%' identified by 'anotherpassword';

二、設定mysql允許遠端連線(ubuntu系統)

1、 sudo vi /etc/mysql/my.cnf

2、注釋掉如下兩行:

bind-address=127.0.0.1

skip-network(mysql5.6版本裡沒有這行)

3、sudo service mysql restart

結合一中的授權,被授權使用者可以遠端訪問

MySql建立使用者並授權

本文簡單描述如何在mysql下完成使用者的建立授權等操作 登陸mysql 使用root使用者登陸mysql jacky gentoo mysql uroot p xx xx代表各自的密碼 mysql create user pysite localhost identified by xx 自此完成...

MySQL 建立使用者並授權

create user username host identified by password 說明 示例 create user jack localhost identified by 123456 create user rose 192.168.38.110 idendified by 1...

mysql建立使用者並授權

create database db create user user identified by pwd grant all privileges on db to user create user user admin identified by pwd grant select,insert,...