{"id":337,"date":"2016-04-26T16:44:29","date_gmt":"2016-04-26T07:44:29","guid":{"rendered":"https:\/\/fsck.jp\/?p=337"},"modified":"2018-06-15T10:06:31","modified_gmt":"2018-06-15T01:06:31","slug":"ubuntu-16-04-mariadb","status":"publish","type":"post","link":"https:\/\/fsck.jp\/?p=337","title":{"rendered":"Ubuntu 16.04 + MariaDB"},"content":{"rendered":"<p>\u203b\u3053\u308c\u306f\u53e4\u3044\u8a18\u4e8b\u3067\u3059\u3002<a href=\"https:\/\/fsck.jp\/?p=793\">Ubuntu 18.04 \u306e\u5834\u5408\u306f\u3053\u3061\u3089<\/a>\u3002<\/p>\n<p>\u203b\u4ee5\u4e0b\u306e\u30b5\u30a4\u30c8\u3092\u53c2\u8003\u306b\u5168\u9762\u6539\u8a02\u3057\u307e\u3057\u305f(2017\/09\/12)<br \/>\n<a href=\"https:\/\/jyn.jp\/ubuntu-16-04-mariadb-password-bug\/\">Ubunt 16.04\u3067MariaDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u5909<\/a><\/p>\n<p>MySQL \u304b\u3089 MariaDB \u306b\u79fb\u884c\u3059\u308b\u306b\u3042\u305f\u3063\u3066\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u524d\u63d0\u3068\u3059\u308b\u6d41\u5100\u304c\u9055\u3063\u305f\u308a\u3001\u7f60\u304c\u3042\u3063\u305f\u308a\u3059\u308b\u306e\u3067\u624b\u5f53\u3066\u3092\u3059\u308b\u3002<\/p>\n<h3>1. DB root \u30e6\u30fc\u30b6\u3067\u306e\u63a5\u7d9a\u306b\u5931\u6557\u3059\u308b<\/h3>\n<p>\u901a\u5e38\u306f\u6700\u521d\u306b DB root \u30e6\u30fc\u30b6\u3067 DB \u30a8\u30f3\u30b8\u30f3\u306b\u63a5\u7d9a\u3057\u3066\u3001Web \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8981\u6c42\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3084DB\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3059\u308b\u3060\u308d\u3046\u3002\u3053\u308c\u3092\u5b9f\u884c\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001OS \u306e\u4e00\u822c\u30e6\u30fc\u30b6\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089 DB \u306b root \u30ed\u30b0\u30a4\u30f3\u3067\u304d\u306a\u3044\u3068\u3044\u3046\u4e8b\u8c61\u306b\u3076\u3061\u5f53\u305f\u308b\u3002<\/p>\n<pre>\r\nuser@xenial:~$ mysql -u root -p\r\nEnter password:\r\nERROR 1698 (28000): Access denied for user 'root'@'localhost'<\/pre>\n<p>mysql_secure_installation\u3067\u521d\u671f\u5316\u3092\u5b9f\u884c\u3057\u3066\u3082\u52b9\u679c\u304c\u306a\u3044\u3002<\/p>\n<p>\u4e0a\u8a18\u52d5\u4f5c\u306e\u539f\u56e0\u306f\u3001\u521d\u671f\u72b6\u614b\u306e DB root \u30e6\u30fc\u30b6\u8a8d\u8a3c\u306b UNIX \u30bd\u30b1\u30c3\u30c8\u8a8d\u8a3c\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u305f\u3081\u3067\u3042\u308b\u3002\u3053\u306e\u72b6\u614b\u3067\u306f\u3001DB root \u3068\u3057\u3066\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306b OS root \u6a29\u9650\u306b\u306a\u3089\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044 (sudo \u307e\u305f\u306f su \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046)\u3002OS root \u306b\u306a\u3063\u3066\u3044\u308c\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30e6\u30fc\u30b6\u540d\u6307\u5b9a\u306a\u3057\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3057\u3067 DB root \u3068\u3057\u3066\u63a5\u7d9a\u53ef\u80fd\u3067\u3042\u308b\u3002<\/p>\n<pre>\r\nuser@xenial:~$ sudo mysql\r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 42\r\nServer version: 10.0.34-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04\r\n\r\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB [(none)]&gt;<\/pre>\n<p>DB root \u3067\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u3068\u3001\u8a8d\u8a3c\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u72b6\u614b\u3082\u78ba\u8a8d\u3067\u304d\u308b\u3002<\/p>\n<pre>MariaDB [(none)]&gt; SELECT user,host,plugin from mysql.user;\r\n+------+-----------+-------------+\r\n| user | host      | plugin      |\r\n+------+-----------+-------------+\r\n| root | localhost | unix_socket |\u3000\u2190unix_socket\u8a8d\u8a3c\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\r\n+------+-----------+-------------+\r\n1 row in set (0.00 sec)<\/pre>\n<h3>2. \u521d\u671f\u72b6\u614b\u306e\u8a8d\u8a3c\u8a2d\u5b9a\u3067\u305d\u306e\u307e\u307e\u5229\u7528\u3059\u308b<\/h3>\n<p>\u3053\u306e\u521d\u671f\u8a2d\u5b9a\u306b\u4e57\u3063\u304b\u3063\u3066\u3044\u304f\u306a\u3089\u3001DB \u306e root \u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u3002<\/p>\n<p>\u307e\u305f\u4e00\u822c\u30e6\u30fc\u30b6\u3067\u3082\u540c\u4e00\u306e\u4ed5\u7d44\u307f\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001UNIX \u30e6\u30fc\u30b6\u3068 DB \u30e6\u30fc\u30b6\u3092\u540c\u540d\u3067\u4f5c\u6210\u3059\u308c\u3070\u3088\u3044\u3002<\/p>\n<p>\u4f8b) wordpress \u3092\u300cwordpress\u300d\u3068\u3044\u3046\u30e6\u30fc\u30b6\u540d\u3067\u5229\u7528\u3059\u308b\u5834\u5408<\/p>\n<pre>user@xenial:~$ sudo useradd -m -s \/bin\/bash wordpress (OS \u30e6\u30fc\u30b6\u306e\u4f5c\u6210)\r\nuser@xenial:~$ sudo mysql\r\nMariaDB [(none)]&gt; CREATE USER wordpress@localhost IDENTIFIED VIA unix_socket; (DB \u30e6\u30fc\u30b6\u306e\u4f5c\u6210)<\/pre>\n<p>wordpress \u30e6\u30fc\u30b6\u3067\u63a5\u7d9a\u3067\u304d\u308b\u304b\u3069\u3046\u304b\u78ba\u8a8d\u3059\u308b\u3002<\/p>\n<pre>user@xenial:~$ sudo -i -u wordpress\r\nwordpress@xenial:~$ mysql -u wordpress\r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 46\r\nServer version: 10.0.34-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04\r\n\r\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB [(none)]&gt; \\q\r\nBye<\/pre>\n<p>\u203b\u4e0a\u8a18\u306e\u65b9\u5f0f\u3067wordpress\u3092\u52d5\u304b\u3059\u5834\u5408\u306f\u3001PHP \u306e\u5b9f\u884c\u30e6\u30fc\u30b6\u304c wordpress \u30e6\u30fc\u30b6\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\u4f8b\u3048\u3070 PHP \u5b9f\u884c\u74b0\u5883\u306b php-fpm \u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001\/etc\/php\/7.0\/fpm\/pool.d\/www.conf\u3092\u7de8\u96c6\u3057\u3066 php-fpm \u5b9f\u884c\u30e6\u30fc\u30b6\u3092 wordpress \u306b\u5909\u66f4\u3059\u308b\u3002<\/p>\n<p>\u203b\u3053\u306e\u8a8d\u8a3c\u65b9\u5f0f\u3067\u306f\u3001TCP\/3306 \u7d4c\u7531\u3067\u306f\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u306a\u3044\u3053\u3068\u306b\u306a\u308b\u3002\u5fc5\u305a\u30ed\u30fc\u30ab\u30eb\u306e UNIX \u30c9\u30e1\u30a4\u30f3\u30bd\u30b1\u30c3\u30c8\u7d4c\u7531\u3067\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/p>\n<h3>3. \u5f93\u6765\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3092\u4f7f\u3063\u3066\u3044\u304f\u5834\u5408<\/h3>\n<p>DB \u306e root \u30e6\u30fc\u30b6\u3092\u5f93\u6765\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u306b\u5909\u66f4\u3057\u305f\u3044 (\u4ee5\u524d\u306e\u65b9\u5f0f\u306b\u623b\u3059) \u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u624b\u9806\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<pre>\r\nuser@xenial:~$ sudo mysql\r\nMariaDB [(none)]&gt; set password for 'root'@'localhost'=password('\u30d1\u30b9\u30ef\u30fc\u30c9\u6587\u5b57\u5217');\r\nMariaDB [(none)]&gt; use mysql;\r\nMariaDB [mysql]&gt; update user set plugin='' where user='root';\r\nMariaDB [mysql]&gt; flush privileges;\r\nMariaDB [mysql]&gt; \\q<\/pre>\n<p>root \u30e6\u30fc\u30b6\u306e\u8a8d\u8a3c\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5916\u3057\u3001\u901a\u5e38\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u3002\u3053\u306e\u5bfe\u51e6\u3092\u5b9f\u65bd\u3057\u305f\u5834\u5408\u306f\u3001\/etc\/mysql\/debian.cnf \u306b\u5e73\u6587\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u3066\u3084\u3089\u306a\u3044\u3068 systemctl \u3067\u306e\u8d77\u52d5\u30fb\u505c\u6b62\u304c\u52d5\u4f5c\u3057\u306a\u304f\u306a\u308b\u3002<\/p>\n<pre>user@xenial:~$ sudo vi \/etc\/mysql\/debian.cnf<\/pre>\n<pre>\r\n[client]\r\nhost     = localhost\r\nuser     = root\r\npassword = root\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u6587\u5b57\u5217\r\nsocket   = \/var\/run\/mysqld\/mysqld.sock\r\n[mysql_upgrade]\r\nhost     = localhost\r\nuser     = root\r\npassword = root\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u6587\u5b57\u5217\r\nsocket   = \/var\/run\/mysqld\/mysqld.sock<\/pre>\n<p>\u4e00\u822c\u30e6\u30fc\u30b6\u306b\u3064\u3044\u3066\u3082\u3001\u901a\u5e38\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u3066\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre>MariaDB [(none)]&gt; CREATE USER wordpress@localhost IDENTIFIED BY '\u30d1\u30b9\u30ef\u30fc\u30c9\u6587\u5b57\u5217';<\/pre>\n<h3>4. localhost \u306e 3306\/tcp \u306b\u63a5\u7d9a\u3067\u304d\u306a\u3044<\/h3>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089 localhost \u3042\u3066\u306b\u63a5\u7d9a\u3059\u308b\u3068\u3001\u30b7\u30b9\u30c6\u30e0\u4e0a IPv6 (::1) \u304c\u512a\u5148\u3055\u308c\u308b\u3002\u3057\u304b\u3057 MariaDB \u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u306e bind-address \u306f 127.0.0.1 \u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<p>\u3053\u306e\u305b\u3044\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u3067\u3001DB \u30b5\u30fc\u30d0\u306e\u30db\u30b9\u30c8\u540d \/ IP \u30a2\u30c9\u30ec\u30b9\u6307\u5b9a\u3092 &#8220;localhost&#8221; \u306b\u3057\u3066\u3042\u308b\u3068\u63a5\u7d9a\u3067\u304d\u306a\u3044\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5074\u3067\u306e DB \u30b5\u30fc\u30d0\u6307\u5b9a\u3092 127.0.0.1 \u3068\u3059\u308b\u304b\u3001MariaDB \u5074\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb \/etc\/mysql\/mariadb.conf.d\/50-server.cnf \u3067 bind-address \u3092 ::1 \u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u203b\u3053\u308c\u306f\u53e4\u3044\u8a18\u4e8b\u3067\u3059\u3002Ubuntu 18.04 \u306e\u5834\u5408\u306f\u3053\u3061\u3089\u3002 \u203b\u4ee5\u4e0b\u306e\u30b5\u30a4\u30c8\u3092\u53c2\u8003\u306b\u5168\u9762\u6539\u8a02\u3057\u307e\u3057\u305f(2017\/09\/12) Ubunt 16.04\u3067MariaDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u5909 MySQL \u304b\u3089 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,9,14,26],"tags":[],"_links":{"self":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts\/337"}],"collection":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337"}],"version-history":[{"count":0,"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts\/337\/revisions"}],"wp:attachment":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}