gpt4 book ai didi

mysql - 复制 MySQL 用户以创建新用户

转载 作者:行者123 更新时间:2023-11-29 23:52:52 26 4
gpt4 key购买 nike

我在许多不同的 MySQL 服务器上有大量这种类型的用户

myuser@localhost
myotheruser@localhost

现在,我想创建新用户,该用户应该与上面的用户具有相同的密码,并且可以访问相同的数据库,但来自不同的主机,如下所示:

myuser@127.0.0.1
myotheruser@127.0.0.1

有没有人有一种快速简便的方法来做到这一点?

最佳答案

我尝试了不同的方法来解决这个问题,但运行这两个命令:

mysqldump --skip-extended-insert mysql user | grep 'localhost' | egrep '^INSERT INTO' | sed 's/localhost/127.0.0.1/g' > add-local-ip-user.sql

mysqldump --skip-extended-insert mysql db | grep 'localhost' | egrep '^INSERT INTO' | sed 's/localhost/127.0.0.1/g' > add-local-ip-db.sql

然后,我只输出内容:

cat add-local-ip*

然后我打开mysql:

mysql mysql

最后粘贴上面的输出,然后运行flush特权有人反对这样做吗?例如这是一个愚蠢的解决方案吗?

关于mysql - 复制 MySQL 用户以创建新用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25524143/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com