{"id":286303,"date":"2017-05-14T19:25:02","date_gmt":"2017-05-14T15:25:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286303"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286303","title":{"rendered":"\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 \u0432 MySql"},"content":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0425\u0430\u0431\u0440\u043e\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e!<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 MySql \u043d\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 MySql \u0438 \u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440. \u0412 \u0441\u0435\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043a\u0440\u0430\u0439\u043d\u0435 \u043c\u0430\u043b\u043e, \u0438 \u0432 \u044d\u0442\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u043d\u0430\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 MySql \u0438 \u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438, \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p>  \u0410\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u043e\u0431\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0441\u0430\u043c\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043a\u0443\u0447\u0435\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432, \u0442\u043e \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0435\u0441\u043b\u0438 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412\u043e\u043e\u0431\u0449\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430: \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c \u0441 MySql, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0442\u0430\u0449\u0438\u0442 \u0438\u0437 \u0431\u0430\u0437\u044b mysql \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438. \u041c\u043d\u0435 \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 php.<\/p>\n<p>  \u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432\u0437\u044f\u0442 <a href=\"https:\/\/gist.github.com\/zaiddabaeen\/e88a2d10528e31cd6692\">gist <\/a>\u043e\u0442 Zaid Daba&#8217;een<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 php \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php \/** Feel free to improve it.  * Original by Janich: https:\/\/gist.github.com\/janich\/6121771  *  * @requires PHP 5.3+  * @package ExportMySQLUsers  * @author Zaid Daba'een  * @license http:\/\/www.dbad-license.org\/ DBAD license  *\/ \/\/ Set up database root credentials $host = 'localhost'; $user = 'root'; $pass = 'your_passwd'; \/\/ ---- Do not edit below this ---- \/\/ Misc settings header('Content-type: text\/plain; Charset=UTF-8'); \/\/ Final import queries goes here $export = array(); \/\/ Connect to database try {     $link = new PDO(&quot;mysql:host=$host;dbname=mysql&quot;, $user, $pass); } catch (PDOException $e) {     printf('Connect failed: %s', $e-&gt;getMessage());     die(); } \/\/ Get users from database \/\/$statement = $link-&gt;prepare(&quot;select `user`, `host`, `authentication_string` FROM `user`&quot;); $statement = $link-&gt;prepare(&quot;select `user`, `host`, `password` FROM `user`&quot;); $statement-&gt;execute(); while ($row = $statement-&gt;fetch()) {     $user   = $row[0];     $host   = $row[1];     $pass   = $row[2];     $export[] = 'CREATE USER \\''. $user .'\\'@\\''. $host .'\\' IDENTIFIED BY \\''. $pass .'\\'';     \/\/ Fetch any permissions found in database     $statement2 = $link-&gt;prepare('SHOW GRANTS FOR \\''. $user .'\\'@\\''. $host .'\\'');     $statement2-&gt;execute();     while($row2 = $statement2-&gt;fetch())     {         $export[] = $row2[0];     } } $link = null; echo implode(&quot;;\\n&quot;, $export);<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u044f MySql<\/p>\n<pre><code class=\"bash\">mysql --version<\/code><\/pre>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0435 5.6, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 5.7<\/p>\n<p>  \u0422\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code class=\"php\">\/\/$statement = $link-&gt;prepare(&quot;select `user`, `host`, `authentication_string` FROM `user`&quot;);<\/code><\/pre>\n<p>  \u0418 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435:<\/p>\n<pre><code class=\"php\">$statement = $link-&gt;prepare(&quot;select `user`, `host`, `password` FROM `user`&quot;);<\/code><\/pre>\n<p>  \u0418\u043d\u0430\u0447\u0435 \u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432\u0441\u0451 \u043a\u0430\u043a \u0435\u0441\u0442\u044c.<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 MySql 5.7 \u043f\u0430\u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0435 authentication_string, \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0432 \u043f\u043e\u043b\u0435 password.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0432\u043e\u0434, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"sql\">CREATE USER 'root'@'localhost' IDENTIFIED BY '*MD5-HASH'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION; GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION; CREATE USER 'mysql.sys'@'localhost' IDENTIFIED BY '*MD5-HASH'; GRANT USAGE ON *.* TO 'mysql.sys'@'localhost'; GRANT TRIGGER ON `sys`.* TO 'mysql.sys'@'localhost'; GRANT SELECT ON `sys`.`sys_config` TO 'mysql.sys'@'localhost'; CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY '*MD5-HASH'; GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' WITH GRANT OPTION; CREATE USER 'your_user'@'localhost' IDENTIFIED BY '*MD5-HASH'; GRANT ALL PRIVILEGES ON `your_DB`.* TO 'your_user'@'localhost' WITH GRANT OPTION;<\/code><\/pre>\n<p>  \u041e\u0442 \u0433\u0440\u0435\u0445\u0430 \u043f\u043e\u0434\u0430\u043b\u044c\u0448\u0435 \u0443\u0434\u0430\u043b\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0438\u0437\u0443\u0447\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434. \u0423\u0434\u0430\u043b\u0438\u043c \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f root.<\/p>\n<p>  \u0422\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0432\u043d\u0435\u0441\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 MySql.<\/p>\n<p>  \u0412\u0441\u0451! \u041e\u0442\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043e \u0432\u0430\u0448\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f \u043b\u044e\u0431\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/328604\/\"> https:\/\/habrahabr.ru\/post\/328604\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0425\u0430\u0431\u0440\u043e\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e!<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 MySql \u043d\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 MySql \u0438 \u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440. \u0412 \u0441\u0435\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043a\u0440\u0430\u0439\u043d\u0435 \u043c\u0430\u043b\u043e, \u0438 \u0432 \u044d\u0442\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u043d\u0430\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 MySql \u0438 \u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438, \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p>  \u0410\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u043e\u0431\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0441\u0430\u043c\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043a\u0443\u0447\u0435\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432, \u0442\u043e \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0435\u0441\u043b\u0438 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-286303","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286303"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286303\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}