Database access and remote access

Create new user

1.create user'test1'@'localhost' identified by '123456';
grant all PRIVILEGES on . To'test1'@'localhost'; grant user permission
FLUSH PRIVILEGES; just refresh

You can use mysql -u test1 -p to access

Create remote user

To operate on computer A, first create a user for the ip of computer B, and grant computer B’s ip access permissions,
1. create user'test2'@'(B's ip)' identified by '123456';
grant all PRIVILEGES on . To 'test1'@'(B's ip)'; Grant user permission
FLUSH PRIVILEGES; just refresh

2. Turn off A's own firewall
3. Access A's database on computer B, use mysql -h (A's ip address) -u test2 -p to
enter the password of test2, and then use computer B as the user test2 to perform data on computer A operating.
ps: You can set the host to %, () is equivalent to opening the local database to all
ips , create user'test3'@'%' identified by '123456';
so all ips can access the local database as test3 .

delete users

mysql>delete from user where user=’test2′ and host=‘localhost’;
mysql>flush privileges;

Grant user permissions

Grant permissions on database objects to users
1. Grant ordinary data users, the right to query, insert, update, and delete all table data in the database.
grant select on testdb.* to common_user@'%'
grant insert on testdb.* to common_user@'%'
grant update on testdb.* to common_user@'%'
grant delete on testdb.* to common_user@'%'
or, Use a MySQL command instead:
grant select, insert, update, delete on testdb.* to common_user@'%'

For other detailed permissions, please refer to the blog below

If you have other detailed requirements, please refer to this blog:
https://blog.csdn.net/xuxile/article/details/53161908

Guess you like

Origin blog.csdn.net/weixin_43722571/article/details/98976785