1、本地的mysql
- 改表法
- 使用命令行修改
登录mysql:mysql -u root -p
使用mysql数据库:mysql>use mysql
修改权限配置:mysql>update user set host = ’%’ where user = ’root’;mysql>select host, user from user;
更新状态:mysql>flush privileges; - 使用Navicat修改
登录Navicat,选择mysql数据库中的user表,添加一条权限用户名:自起(root或者任意),主机名:%,其他参考 localhost - root这一行。
- 授权法
如果你想root使用password从任何主机连接到mysql服务器的话
使用:
mysql>GRANT ALL PRIVILEGES ON*.*
TO ’root’@’%’ IDENTIFIED BY ’password’ WITH GRANT OPTION;
mysql>flush privileges;
2、XAMPP中的mysql
-
修改mysql\bin\my.ini文件,找到# bind-address="127.0.0.1"这一行,改成# bind-address=“0.0.0.0”
-
修改phpMyAdmin\config.inc.php文件,找到
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
修改成:
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
-
重新启动mysql和Apache
1、进入phpmyadmin管理界面首页,点击“账户”后,再“添加新用户”,用户名:root(随意),主机:%(必须是%),对应的密码可以设置可以不设置,即可开通远程连接;
2、或者用工具Navicat链接到本地数据,点击“管理用户”,添加用户进行设置。