Home > Database > Mysql Tutorial > mysql快速导出user权限

mysql快速导出user权限

WBOY
Release: 2016-06-07 16:37:39
Original
879 people have browsed it

总是有各种各样的mysql数据库用户权限的导出,在此总结一条命令,快速导出,提高效率。 echo select concat(show grants for ,user,@,host, ;') from mysql.user where user like XXX_%|/usr/local/mysql/bin/mysql -u$user -P$port -p$pass |grep -v ^conca

总是有各种各样的mysql数据库用户权限的导出,在此总结一条命令,快速导出,提高效率。

echo “select concat(‘show grants for ”’,user,”’@”’,host, ”’;') from mysql.user where user like ‘XXX_%’”|/usr/local/mysql/bin/mysql -u$user -P$port -p$pass |grep -v ‘^concat’|/usr/local/mysql/bin/mysql -u$user -P$port -p$pass |grep -v ‘^Grants for’|sed “s/$/&;/” ?>createuser.sql

PS:

XXX:需要匹配的数据库

$user:导出数据要使用的mysql账户

$port:端口号

$pass:导出数据要使用的mysql账户的密码

导出生成的文件createuser.sql可以直接使用以下命令导入到新的数据库服务器中

/usr/local/mysql/bin/mysql -u$user -P$port -p$pass

如此简单,再不用一条一条命令执行了,偶觉得怎样思考高效的工作是更有市场滴O(∩_∩)O~~

无觅相关文章插件,快速提升流量

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template