{"id":78,"date":"2023-01-17T20:07:30","date_gmt":"2023-01-17T11:07:30","guid":{"rendered":"https:\/\/blog.tsnet.dyndns.org\/?p=78"},"modified":"2023-01-19T18:11:38","modified_gmt":"2023-01-19T09:11:38","slug":"mysql-mariadb%e3%80%80%e3%80%80%e3%80%80%e3%80%80%e3%83%90%e3%83%83%e3%82%af%e3%82%a2%e3%83%83%e3%83%97","status":"publish","type":"post","link":"https:\/\/blog.tsnet.dyndns.org\/?p=78","title":{"rendered":"MySQL MariaDB \u30d0\u30c3\u30af\u30a2\u30c3\u30d7"},"content":{"rendered":"\n<h3 class=\"has-vivid-red-color has-text-color wp-block-heading\">MySQL,MariaDB\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u3000\u3000\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b<\/h3>\n\n\n\n<p class=\"has-large-font-size\">mysqldump\u306e\u4f7f\u7528<\/p>\n\n\n\n<p><strong>\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-base-color has-contrast-background-color has-text-color has-background\"># mysqldump -uroot -p<em>PASSWORD<\/em> <em>DBNAME<\/em> &gt; <em>BACKUPFILE<\/em><\/pre>\n\n\n\n<p>-uroot  root\u30e6\u30fc\u30b6\u30fc\u3067\u5b9f\u884c\u3000-p<em>PASSWORD<\/em>  root\u30e6\u30fc\u30b6\u30fc\u306e\u30d1\u30b9\u30ef\u30fc\u30c9<em>PASSWORD<\/em>\u3092\u7701\u7565\u3059\u308b\u3068\u5b9f\u884c\u6642\u306b\u5165\u529b\u3092\u6c42\u3081\u3089\u308c\u308b\u3000<em>DBNAME<\/em>\u3000\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u540d\u524d\u3000<em>BACKUPFILE<\/em>\u3000\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d<\/p>\n\n\n\n<p><strong>\u4e3b\u306a\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-contrast-color has-pale-cyan-blue-background-color has-text-color has-background\">--user=<em>USER<\/em> (-u<em>USER<\/em>) mysqldump\u3092\u5b9f\u884c\u3059\u308b\u30e6\u30fc\u30b6\u30fc\n--password=<em>PASSWORD<\/em> (-p<em>PASSWORD<\/em>) USER\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\n--add-drop-database create database\u6587\u306e\u524d\u306b drop database\u6587\u3092\u5165\u308c\u308b\n--all-databases (-A) \u3059\u3079\u3066\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5bfe\u8c61\u306b\u3059\u308b\n--quick (-q) \u30e1\u30e2\u30ea\u306b\u30d0\u30c3\u30d5\u30a1\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u306a\u304f1\u884c\u305a\u3064\u30c0\u30f3\u30d7\u3059\u308b,\u30e1\u30e2\u30ea\u3092\u7bc0\u7d04\u3059\u308b\n--flushu-logs (-F) dump\u3092\u59cb\u3081\u308b\u524d\u306b\u30b5\u30fc\u30d0\u30fc\u30ed\u30b0\u3092\u30d5\u30e9\u30c3\u30b7\u30e5\u3059\u308b\n--single-transaction\u3000\u4e00\u8cab\u6027\u3092\u4fdd\u3061\u3064\u3064\u30c6\u30fc\u30d6\u30eb\u3092\u30ed\u30c3\u30af\u3057\u306a\u3044\u3067\u30c0\u30f3\u30d7\u3059\u308b\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u203b()\u5185\u306f\u77ed\u7e2e\u5f62<\/pre>\n\n\n\n<h3 class=\"has-vivid-red-color has-text-color wp-block-heading\">\u6bce\u65e5\u81ea\u52d5\u3067\u30d0\u30c3\u30af\u30a2\u30c3\u30d7<\/h3>\n\n\n\n<p><strong>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5c02\u7528\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210<\/strong><\/p>\n\n\n\n<p>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5c02\u7528\u30e6\u30fc\u30b6\u30fc\u3092<strong>bkupusr<\/strong>\u3068\u3057\u3066<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-base-color has-contrast-background-color has-text-color has-background\"># mysql -u root -p\nEnter password:<em>PASSWORD<\/em>\nroot@localhost [none]&gt;GRANT RELOAD,SELECT,FILE,LOCK TABLES ON *.* TO 'bkupusr'@'localhost' IDENTIFIED BY '<em>PASSWORD<\/em>';<\/pre>\n\n\n\n<p>bkupusr\u306b\u306f\u3059\u3079\u3066\u306e\u6a29\u9650\u3092\u4e0e\u3048\u306a\u3044<\/p>\n\n\n\n<p><strong>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u7528\u30b9\u30af\u30ea\u30d7\u30c8dbdump.sh\u3092\u4f5c\u6210<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-base-color has-contrast-background-color has-text-color has-background\">#!\/bin\/sh\numask 077\n\nDATE=`date +%Y%m%d`\nBkupDir=\"\/home\/<em>XXX<\/em>\/dbdump\"\n\nmysqldump -ubkupusr -p<em>PASSWORD<\/em> -F -q --single-transaction --add-drop-database --all-databases &gt; ${BkupDir}\/${DATE}.dump\n\nfind ${BkupDir} -mtime +7 -exec rm -f {} \\;<\/pre>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u540d\u3092<strong>yyyymmdd.dump<\/strong>\u3000\u4fdd\u5b58\u5148\u3092<em>XXX<\/em>\u30e6\u30fc\u30b6\u30fc\u306e\u30db\u30fc\u30e0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e<strong>dbdump<\/strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3059\u308b\u30017\u65e5\u3092\u904e\u304e\u305f\u30d5\u30a1\u30a4\u30eb\u306f\u524a\u9664\u3059\u308b<\/p>\n\n\n\n<p>\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u5b9f\u884c\u6a29\u3092\u4e0e\u3048\u3001<strong>\/root\/bin<\/strong>\u306b\u914d\u7f6e\u3059\u308b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-base-color has-contrast-background-color has-text-color has-background\"># chmod 755 dbdump.sh\n# mkdir \/root\/bin\n# mv dbdump.sh \/root\/bin<\/pre>\n\n\n\n<pre id=\"block-16405089-94f4-4e26-bf21-30c20ef2f772\" class=\"wp-block-preformatted\"><strong>\u6bce\u65e5\u5b9a\u6642\u306b\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\/etc\/crontab\u3092\u8a2d\u5b9a\u3059\u308b<\/strong><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-base-color has-contrast-background-color has-text-color has-background\">SHEL=\/bin\/sh\nPATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin ***** <strong>:\/root\/bin<\/strong>\n#minute hour    mday    month   wday    who     command\n                       :\n5       2        *        *      *      root    dbdump.sh\n                       :<\/pre>\n\n\n\n<p>\u6bce\u65e5\u5348\u524d2\u6642\uff15\u5206\u306broot\u30e6\u30fc\u30b6\u30fc\u3067dbdump.sh\u3092\u5b9f\u884c\u3059\u308b \u203bcron\u3067\u306f\u74b0\u5883\u5909\u6570\u306f\u4f7f\u308f\u308c\u306a\u3044\u306e\u3067crontab\u5185\u3067PATH\u306b\/root\/bin\u3092\u8ffd\u52a0\u3059\u308b<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL,MariaDB\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u3000\u3000\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b mysqldump\u306e\u4f7f\u7528 \u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9 # mysqldump -uroot -pPASSWORD DBNAME &gt; BACKUPFILE -uro [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,8],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-freebsd","category-mysql-mariadb"],"_links":{"self":[{"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78"}],"version-history":[{"count":18,"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.tsnet.dyndns.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}