允许用户root从ip为192.168.2.2的主机连接到mysql服务器,并使用123456作为密码
MariaDB [(none)]> grant all privileges on *.* to 'root'@'192.168.2.2' identified by '123456' with grant option;
若是允许所有ip:
GRANT ALL PRIVILEGES ON *.* TO root@'%’ IDENTIFIED BY '123456' WITH GRANT OPTION;
最后执行
MariaDB [(none)]> flush privileges; //刷新权限缓存
MariaDB [(none)]> show privileges;
MariaDB [(none)]> show grants for 'testuser'@'222.129.1.1'