给mysql赋予连接的权限

来源:互联网 发布:小红帽linux安装教程 编辑:程序博客网 时间:2024/05/02 04:53

mysql服务器装好以后,默认只能在localhost上登录,如果你要是从另外的IP地址登录,即使是本机登录也会出现问题。

mysql -h 192.168.2.48 -u root -pwow8;
ERROR 1130 (00000): Host '192.168.2.48' is not allowed to connect to this MySQL server

查看mysql手册,1130表示如下

·        错误:1130 SQLSTATE: HY000 (ER_HOST_NOT_PRIVILEGED)

消息:不允许将主机'%s'连接到该MySQL服务器。

所以需要在mysql服务器上打开相应的权限,下面几步可以是root用户在所有的机器上以wow8登录

[zhoulei@localhost ~]$ mysql -u root;
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.59-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'wow8' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH   PRIVILEGES;  
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye


原创粉丝点击