First, declare that, in general, you need to have the root permission in MySQL to modify the mysql password and grant permissions. Note: this operation is performed at the WIN command prompt, and phpMyAdmin is also applicable. User: phplamp user database: phplampDB1.MySQL command line to create a user login, first declare: Generally, you need to have the root permission in MySQL to modify the mysql password and authorize.
Note: this operation is performed at the WIN command prompt, and phpMyAdmin is also applicable.
User: phplamp
User Database: phplampDB
1. create a user using the MySQL command line
// Log on to MYSQL
@> Mysql-u root-p
@> Password
// Create a user
Mysql> insert into mysql. user (Host, User, Password) values ('localhost', 'phplam', password ('123 '));
// Refresh the system permission list
Mysql> flush privileges;
In this way, a user named: phplamp password: 1234 is created.
// Log on after exiting
Mysql> exit;
@> Mysql-u phplamp-p
@> Enter the password
Mysql> logon successful
2. user authorization for MySQL commands
// Log on to MYSQL (with ROOT permission ). I log on as ROOT.
@> Mysql-u root-p
@> Password
// Create a database for the user (phplampDB)
Mysql> create database phplampDB;
// Authorize the phplamp user to have all permissions for the phplamp database
@> Grant all privileges on phplampDB. * to phplamp @ localhost identified by '123 ';
// Refresh the system permission list
Mysql> flush privileges;
Mysql> Other operations
// If you want to assign some permissions to a user, you can write as follows:
Mysql> grant select, update on phplampDB. * to phplamp @ localhost identified by '123 ';
// Refresh the system permission table.
Mysql> flush privileges;
Mysql> grant permission 1, permission 2 ,... Permission n on database name. table name to user name @ user address identified by 'connection password ';
Permission 1, permission 2 ,... Permission n indicates 14 permissions, including select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process, and file.
When permission 1, permission 2 ,... Permission n is replaced by all privileges or all, indicating that all permissions are granted to the user.
When the database name. table name is replaced by *. *, it grants the user the permission to operate all the tables in the database on the server.
The user address can be localhost, IP address, machine name, or domain name. You can also use '%' to connect from any address.
The 'connection password' cannot be blank; otherwise, creation fails.
For example:
Mysql> grant select, insert, update, delete, create, drop on vtdc. employee to joe@10.163.225.87 identified by '123 ′;
Assign the user joe from 10.163.225.87 the permission to perform select, insert, update, delete, create, drop, and other operations on the database's vtdc employee table, and set the password to 123.
Mysql> grant all privileges on vtdc. * to joe@10.163.225.87 identified by '000000 ′;