Đăng nhập MySQL
# mysql -u root -p12345
Tạo database
> create database dbname;
Tạo và thiết lập quyền cho user
> create user 'username'@'localhost' identified by 'password';
Thay đổi password user
>set password for 'username'@'localhost' = password('password');
Thiết lập tất cả quyền cho user
> grant all on dbname.* to username@localhost;
Nếu bạn muốn giới hạn quyền cho user thì dùng dòng lệnh sau
> grant SELECT on dbname.* to username@localhost; // SELECT là quyền
Danh sách các quyền bạn có thể thiết lập cho user
ALL ALTER CREATE VIEW CREATE DELETE DROP GRANT OPTION INDEX INSERT SELECT SHOW VIEW TRIGGER UPDATE Reload all the privileges FLUSH PRIVILEGES; Thoát exit
Chúc các bạn thành công!