Some basic commands: logon: mysql-uusername-p: show all databases: showdatabases; use a database: usedatabasename; show all tables of a database: showtables; exit: quit; some basic commands for deleting databases and data tables:
Logon:
Mysql-u username-p
Show all databases:
Show databases;
Use a database:
Use databasename;
Display All tables of a database:
Show tables;
Exit:
Quit;
Delete databases and data tables
Mysql> drop database name;
Mysql> drop table data table name;
User-related: View all users:
Select distinct concat ('User: ''', User, ''' @ ''', host, '''; ') AS query FROM mysql. user;
New user:
Insert into mysql. user (Host, User, Password) values ("localhost", "test", password ("1234 "));
The last three parameters are logon ip address, user name, and password.
Authorize a User:
Format: grant permission on database. * to username @ login host identified by "password"; example: grant all privileges on testDB. * to test @ localhost identified by '123 ';
Then execute the command to refresh the permission: flush privileges;
Grant some permissions to a user:
Grant select, update on testDB. * to test @ localhost identified by '20140901 ';
Grant certain permissions to all databases of a user:
Grant select, delete, update, create, drop on *. * to test @ "%" identified by "1234 ";
Delete a user:
Delete FROM user Where User = 'test' and Host = 'localhost ';
Then refresh the permission;
Delete Account and permissions:> drop user username @ '% ';
> Drop user username @ localhost;
Change the password of a specified user
Use root to log on:
Mysql-u root-p
Run the following command:
Update mysql. user set password = password ('New password') where User = "test" and Host = "localhost ";
Refresh permission:
Flush privileges;