Site Tools


mysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mysql [2012/11/08 11:18] paulsmithmysql [2014/05/13 00:09] (current) paulsmith
Line 1: Line 1:
 +====== MySql ======
  
 +===== Gentoo create inital db =====
 +emerge --config =dev-db/mysql-5.5.28
 +
 +
 +===== Add a user =====
 +  GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
 +  FLUSH PRIVILEGES;
 +
 +====== Export Users an perms ======
 +<code>
 +mysql --batch --skip-column-names --execute="select concat('CREATE USER ''',user,'''@''',host,''' IDENTIFIED BY ''',Password,''';') from user where Password <> '''''';" mysql > mysql-users.sql
 +
 +mysql --batch --skip-column-names --execute="SELECT DISTINCT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') AS query FROM user" mysql | mysql --batch --skip-column-names mysql | perl -p -e '$_ =~ s/$/;/; END { print "FLUSH PRIVILEGES;\n" }' > mysql-grants.sql
 +
 +
 +use mysql;
 +select concat('CREATE USER `',user,'`@`',host,'` IDENTIFIED BY `',Password,'`') from user;
 +</code>