MySql建立資料庫和使用者,並配置許可權後匯入資料

2021-10-23 01:49:15 字數 861 閱讀 3471

進入資料庫

mysql -u root -p
輸入密碼後登入成功,使用create新建資料庫

create database 資料庫名稱 ;
檢視所有資料庫

show databases;
新建資料庫使用者:username為資料庫使用者名稱,localhost為連線方式,userpassword為資料庫密碼

create user 『username'@'localhost' identified by 『userpassword';
驗證賬號是否建立成功

select host, user, password from mysql.user where user='username';
賦予使用者資料庫許可權:all代表所有許可權,databasename為資料名稱,星號代表所有表,也可單獨指定表名,username為要賦予許可權的使用者名稱

grant all on databasename.* to 'username'@'localhost';
檢視使用者許可權

show grants for 'username'@'localhost';
最後重新整理許可權使得配置生效

flush privileges;
接下來匯入資料:abc為資料庫名稱

use abc;
設定資料庫編碼

set names utf8;

mysql建立資料庫並建立使用者授權

create user myuser identified by mypassword 建立乙個不受主機限制的使用者myuser,並且指定密碼是mypassword create user myuser localhost identified by mypassword 或者create user...

mysql資料庫和使用者建立

1.建立資料庫 create database test 2.建立使用者 任何終端都可以連線 grant select,insert,update,delete on test.to user identified by 123456 只讓某個位址段連線 grant select,insert,up...

mysql 建立資料庫和使用者

1 用管理員賬號登陸mysql 2 建立資料庫 create database db01 3 建立使用者 create user user01 localhost identified by password1 user01只能本地訪問 create user user02 identified b...