今在服务器上 有mysql 数据库,远程访问,不想公布root账户,所以,创建了demo账户,允许demo账户在任何地方都能访问mysql数据库中shandong库。
方案一:
在安装mysql的机器上运行:
1: 创建user用户
CREATE USER demo IDENTIFIED BY “123456”
2、
mysql>GRANT ALL PRIVILEGES ON shandong.* TO 'demo'@'%'WITH GRANT OPTION
//赋予任何主机访问数据的权限,也可以如下操作
GRANT ALL PRIVILEGES ON shandong.* TO 'demo'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
3、
mysql>FLUSH PRIVILEGES
//修改生效
4、
mysql>EXIT
//退出MySQL服务器,这样就可以在其它任何的主机上以demo身份登录
引用
另外,当用客户端连接 mysql 时,发现无法连接,看来需要对用户进行重新授权。操作如下:
[root@cicro108 mysql]# bin/mysql -uroot -p -h 127.0.0.1 -A cws3
Enter password:
Welcome to the MySQL monitor. Commands end with or /g.
Your MySQL connection id is 1863 to server version: 4.1.20-standard
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> grant ALL PRIVILEGES ON *.* to root@"%" identified by "mysql" ;
Query OK, 0 rows affected (0.17 sec)
发现这样更改权限以后,远程仍然不能连接,但是用下面的操作就可以了。
mysql> grant ALL PRIVILEGES ON *.* to root@"%" identified by "mysql" WITH GRANT OPTION;
Query OK, 0 rows affected (0.17 sec)
此刻, root 可以被远程连接,当然这里建立其他非 root 用户也可以远程连接。
方案二:
MySQL 1130错误解决方法:
通过MySQL-Front或MySQL administrator连接MySQL的时候发生的这个错误
ERROR 1130: Host ***.***.***.*** is not allowed to connect to this MySQL server
说明所连接的用户帐号没有远程连接的权限,只能在本机(localhost)登录。
需更改 MySQL 数据库里的 user表里的 host项
把localhost改称%
具体步骤:登陆到MySQL
首先 use MySQL;
按照别人提供的方式update的时候,出现错误。
MySQL> update user set host='%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
然后查看了下数据库的host信息如下:
MySQL> select host from user where user = 'root';
+-----------------------+
| host |
+-----------------------+
| % |
| 127.0.0.1 |
| localhost.localdomain |
+-----------------------+
3 rows in set (0.00 sec)
host已经有了%这个值,所以直接运行命令:
MySQL>flush privileges;
再用MySQL administrator连接...成功!!
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Bootstrap table学习笔记(2) 前后端分页模糊查询
![](https://img.aspxhome.com/file/2023/6/132836_0s.jpg)
Python 普通最小二乘法(OLS)进行多项式拟合的方法
![](https://img.aspxhome.com/file/2023/0/87800_0s.jpg)
oracle中to_date详细用法示例(oracle日期格式转换)
Python 3.x基础实战检查磁盘可用空间
PHP与以太坊交互详解
python中关于xmltodict的使用
![](https://img.aspxhome.com/file/2023/0/105010_0s.png)
Python画图高斯分布的示例
Python自动化办公之Excel数据的写入
![](https://img.aspxhome.com/file/2023/9/98929_0s.jpg)
过期软件破解办法实例详解
![](https://img.aspxhome.com/file/2023/4/129484_0s.png)
用gpu训练好的神经网络,用tensorflow-cpu跑出错的原因及解决方案
![](https://img.aspxhome.com/file/2023/5/127255_0s.jpg)
Python基于Opencv识别两张相似图片
![](https://img.aspxhome.com/file/2023/6/70786_0s.jpg)
Python使用Pillow进行图像处理
![](https://img.aspxhome.com/file/2023/6/127086_0s.jpg)
Python中使用ipython的详细教程
![](https://img.aspxhome.com/file/2023/4/85024_0s.png)
JavaScript的私有成员
vue项目中的数据变化被watch监听并处理
python打开windows应用程序的实例
详谈mysqldump数据导出的问题
mysql设置远程访问数据库的多种方法
pygame库实现移动底座弹球小游戏
![](https://img.aspxhome.com/file/2023/5/134465_0s.gif)