异机连接mysql时user表内的用户权限设置
2010-11-01 18:06
666 查看
默认情况下Linux内的mysql数据库mysql,user表内的用户权限只是对localhost即本机才能登陆。需要更改权限:
如下的方式确认:
root#mysql -h localhost-u mysql -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 4 to server version: 4.0.20a-debug
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> use mysql; (此DB存放MySQL的各种配置信息)
Database changed
mysql> select host,user from user; (查看用户的权限情况)
+-------------+-------+
| host | user |
+-------------+-------+
| localhost | |
| localhost | root |
| localhost | |
| localhost | mysql |
+-------------+-------+
6 rows in set (0.02 sec)
由此可以看出,只能以localhost的主机方式访问。
解决方法:
mysql> Grant all privileges on *.* to 'root'@'%' identified by ‘password’with grant option;
(%表示是所有的外部机器,如果指定某一台机,就将%改为相应的机器名;‘root’则是指要使用的用户名,)
mysql> flush privileges; (运行为句才生效,或者重启MySQL)
Query OK, 0 rows affected (0.03 sec)
mysql> select host,user from user; (再次查看用户的权限情况)
+-------------+-------+
| host | user |
+-------------+-------+
| % | mysql |
| % | root |
| localhost | |
| localhost | root |
| localhost | |
| localhost | mysql |
+-------------+-------+
mysql>exit
现在再试试:
root#mysql -h mysql -u root -p
Enter password:******
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 9 to server version: 4.0.20a-debug
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
就成功连接上了。
关于在user表里使用GRANT语句增添新用户:(
GRANT语句安装3个新用户:
monty:可以从任何地方连接服务器的一个完全的超级用户,但是必须使用一个口令 ('something'做这个。注意,我们必须对 monty@localhost和monty@"%"发出GRANT语句。如果我们增加localhost条目,对localhost的匿名用户条目在我 们从本地主机连接接时由mysql_install_db创建的条目将优先考虑,因为它有更特定的Host字段值,所以以user表排列顺序看更早到来。
admin:可以从localhost没有一个口令进行连接并且被授予reload 和process管理权限的用户。这允许用户执行mysqladmin reload、mysqladmin refresh和mysqladmin flush-*命令,还有mysqladmin processlist。没有授予数据库有关的权限。他们能在以后通过发出另一个GRANT语句授权。
dummy:可以不用一个口令连接的一个用户,但是只能从本地主机。全局权限被设置为'N'--USAGE权限类型允许你无需权限就可设置一个用户。它假定你将在以后授予数据库相关的权限。
注意:
以上的设置不紧是对本机的用户使用权限的更改,在所有外部的机器上都可以使用指定的用户登陆连接。当使用mysql-front在windows下管理数据库时,可能由于版本的问题有些程序不支持使用密码,出现以下提示:
1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client
可以使用mymanager来管理mysql。
如下的方式确认:
root#mysql -h localhost-u mysql -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 4 to server version: 4.0.20a-debug
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> use mysql; (此DB存放MySQL的各种配置信息)
Database changed
mysql> select host,user from user; (查看用户的权限情况)
+-------------+-------+
| host | user |
+-------------+-------+
| localhost | |
| localhost | root |
| localhost | |
| localhost | mysql |
+-------------+-------+
6 rows in set (0.02 sec)
由此可以看出,只能以localhost的主机方式访问。
解决方法:
mysql> Grant all privileges on *.* to 'root'@'%' identified by ‘password’with grant option;
(%表示是所有的外部机器,如果指定某一台机,就将%改为相应的机器名;‘root’则是指要使用的用户名,)
mysql> flush privileges; (运行为句才生效,或者重启MySQL)
Query OK, 0 rows affected (0.03 sec)
mysql> select host,user from user; (再次查看用户的权限情况)
+-------------+-------+
| host | user |
+-------------+-------+
| % | mysql |
| % | root |
| localhost | |
| localhost | root |
| localhost | |
| localhost | mysql |
+-------------+-------+
mysql>exit
现在再试试:
root#mysql -h mysql -u root -p
Enter password:******
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 9 to server version: 4.0.20a-debug
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
就成功连接上了。
关于在user表里使用GRANT语句增添新用户:(
GRANT语句安装3个新用户:
monty:可以从任何地方连接服务器的一个完全的超级用户,但是必须使用一个口令 ('something'做这个。注意,我们必须对 monty@localhost和monty@"%"发出GRANT语句。如果我们增加localhost条目,对localhost的匿名用户条目在我 们从本地主机连接接时由mysql_install_db创建的条目将优先考虑,因为它有更特定的Host字段值,所以以user表排列顺序看更早到来。
admin:可以从localhost没有一个口令进行连接并且被授予reload 和process管理权限的用户。这允许用户执行mysqladmin reload、mysqladmin refresh和mysqladmin flush-*命令,还有mysqladmin processlist。没有授予数据库有关的权限。他们能在以后通过发出另一个GRANT语句授权。
dummy:可以不用一个口令连接的一个用户,但是只能从本地主机。全局权限被设置为'N'--USAGE权限类型允许你无需权限就可设置一个用户。它假定你将在以后授予数据库相关的权限。
注意:
以上的设置不紧是对本机的用户使用权限的更改,在所有外部的机器上都可以使用指定的用户登陆连接。当使用mysql-front在windows下管理数据库时,可能由于版本的问题有些程序不支持使用密码,出现以下提示:
1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client
可以使用mymanager来管理mysql。
相关文章推荐
- 异机远程连接mysql时user表内的用户权限设置
- 设置Ubuntu MySQL-sever 用户连接权限
- mysql 用户权限配置(mysql.user表的设置)
- Mysql用户密码设置修改和权限分配
- mysql 用户管理和权限设置
- mysql创建用户以及设置该用户有权限的库
- [置顶] mysql设置用户权限
- [置顶] mysql设置用户权限
- MYSQL 更改数据库data存储目录 创建用户 创建权限 设置远程访问的权限.
- MySql用户权限设置
- mysql 查看当前登陆用户匹配原则及权限user()与current_user()
- linux系统下设置远程连接mysql数据库(以及删除用户权限)
- mysql 用户管理和权限设置
- Mysql权限控制 - 允许用户远程连接
- Mysql用户密码设置修改和权限分配
- mysql grant用户权限设置
- mysql 用户管理和权限设置
- MYSQL远程登录权限设置 ,可以让Navicat远程连接服务器的数据库
- MySQL的用户权限设置问题(如何解决Access denied)
- [置顶] mysql设置用户权限