首先进入mysql:
mysql -u root
如果有密码会提示输入密码
然后输入如下授权代码,
如下即授权用户root使用密码admin123从任何主机连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘admin123‘ WITH GRANT OPTION; flush privileges;
如果只需要某一个ip段访问,可以参考下面:
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.%‘ IDENTIFIED BY ‘admin123‘ WITH GRANT OPTION; flush privileges;
时间: 2024-11-13 09:07:37