A brief short linux how to and problem solving. This blog is intended to be a reference by summarizing from reliable data source and my experience. Readers should have a basic understanding about linux.
วันพุธที่ 14 มีนาคม พ.ศ. 2555
mysql user copy/migration
gensqluser.sh : this script will gen sql statement for creating new user
---
mygrants()
{
mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
) AS query FROM mysql.user" | \
mysql $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}
mygrants --host=localhost --user=username--password=password
---
host1# ./gensqluser.sh >> user.sql
host2# mysql -u -p < user.sql
bash script read file line by line
#/bin/bash
while read myline
do
echo $myline
done < inputfile
while read myline
do
echo $myline
done < inputfile
สมัครสมาชิก:
บทความ (Atom)