Step 1: Enter MySQL
mysql -uroot msyql -p Enter the password of the root user (specified by yourself when installing mysql)
Create a test user, the password is test, "%" means that all users in the network can access the database with the test user name (all tables in all databases);
grant all on *.* to 'test'@'%' identified by 'test';
and comment the bind-address line in /etc/mysql/mysql.cnf
To access all tables in a_db, use the following statement
grant all on a_db.* to 'test'@'%' identified by 'test';
Restrict permissions, restrict the test user to only query all tables in a_db
grant select on a_db.* to 'test'@'%' identified by 'test';
View all database users in mysql
select distinct concat('User: ''',user,'''@''',host,''';') as query from mysql.user;
User authorization to be created;
GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'%' ;
delete test user
delete from user where User='test' and Host='%';
flush privileges;
enter user
mysql> use username
Display the current operating user
mysql> show database();
或SELECT database();
. Realize
mysql> show tables through show tables;
Note: Pay attention to check the column header form, the format is: Tables_in_[db_name]
. Realize
mysql> status through status;
View the user table and enter the user as mysql;