1. Add a user to Mysql
Format: grant select on database. * to "username" @ "Login host" identified by "password ";
Example 1: Add a user named "test1" with the password "abc" so that the user can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to MYSQL, and then type the following command:
Grant select, insert, update, delete on *. * to "test1" @ "%" Identified by "abc ";
Add all permission statements:
Run the following command in Example 1: select, insert ,....) changed to "all privileges", which indicates that all permissions are granted, including database creation permissions and database deletion permissions, and are no longer limited to operations in one database.
Grant all privileges on *. * TO 'root' @ '% 'identified BY '123 ';
Example 2: Add a user named "test2" with the password "abc" so that the user can only log on to localhost, you can also query, insert, modify, and delete the database mydb (localhost refers to the local host, that is, the host where the MYSQL database is located), so that the user knows the password of test2, he cannot access the database directly from the internet, but can only access the database through the web pages on the MYSQL host.
Grant select, insert, update, delete on mydb. * to "test2" @ localhost identified by "abc ";
2. mysql queries all users
All user information in mysql is stored in the mysql. user table.
Select user from mysql. user;
3. Start and Stop the mysql Service
Net stop mysql
Net start mysql
4. log on to mysql
Syntax: mysql-u user name-p user password-h Host ip Address
5. display table structure
Describe table name;
6. Export data
Mysqldump-u root-p database name-h IP address> f:/a. SQL
7. Import Data
Mysqldump-u root-p -- default-character-set = utf8 database name <f:/a. SQL
8. Specify the character set of the database to avoid garbled characters)
Create database wikidb1 character set utf8;
The data is stored in binary format, and the character set must be specified for access.