grant all on *.* to 'user1' identified by 'passwd'; #创建user1赋予all所有权限。
grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.133.1' identified by 'passwd'; #创建user2并指定登陆IP为192.168.133.1,然后赋予select,update,insert权限作用于db1数据库下的所有表。
grant all on db1.* to 'user3'@'%' identified by 'passwd'; #%通配所有ip
show grants; #查看权限
show grants for user2@192.168.133.1; #查看指定用户权限
连接MySQL
mysql -uroot -p123456
mysql -uroot -p123456 -h127.0.0.1 -P3306 #通过ip端口登陆
mysql -uroot -p123456 -S/tmp/mysql.sock #通过sock登陆
mysql -uroot -p123456 -e “show databases” #登陆后操作某条命令