Home  >  Article  >  Database  >  MySQL 5.5权限导出脚本_MySQL

MySQL 5.5权限导出脚本_MySQL

WBOY
WBOYOriginal
2016-06-01 13:34:12816browse

bitsCN.com

MySQL 5.5权限导出脚本

 

[plain]

#!/bin/sh  

  

base_dir='/opt/soft/mysql'  

mysql_user='root'  

mysql_pwd='123456'  

mysql_socket='/tmp/mysql.sock'  

msyql_grants='/tmp/mysql_grants.sql'  

  

result=`${base_dir}/bin/mysql -u${mysql_user} -p${mysql_pwd} -S${mysql_socket} -N -e "select CONCAT('show grants for /'',user,'/'@/'',host,'/';') from mysql.user"`  

#echo ${result}  

${base_dir}/bin/mysql -u${mysql_user} -p${mysql_pwd} -S${mysql_socket} -N -e "${result}" > ${msyql_grants}  

  

sed -i "s/$/;/g" ${msyql_grants}  

  

cat ${msyql_grants}  

  

rm -f ${msyql_grants}  

 

bitsCN.com
Statement:
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