{"id":192085,"date":"2020-06-04T09:47:04","date_gmt":"2020-06-04T01:47:04","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=192085"},"modified":"2020-06-22T08:40:42","modified_gmt":"2020-06-22T00:40:42","slug":"ubuntu-install-mariadb","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ubuntu-install-mariadb.html","title":{"rendered":"\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nMariaDB\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf,\u5b83\u6700\u521d\u88ab\u8bbe\u8ba1\u4e3a\u4e00\u4e2a\u5411\u540e\u517c\u5bb9\u7684\u3001\u4e8c\u8fdb\u5236\u7684\u5373\u63d2\u5373\u7528\u7684\u66ff\u4ee3MySQL\u7684\u7cfb\u7edf\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

MariaDB\u7531MySQL\u7684\u539f\u59cb\u5f00\u53d1\u8005\u548c\u5f00\u6e90\u793e\u533a\u5f00\u53d1\u548c\u7ef4\u62a4,\u8fd9\u91cc\u6211\u4eec\u6765\u4ecb\u7ecd\u5982\u4f55\u5728Ubuntu 20.04\u4e0a\u5b89\u88c5\u548c\u4fdd\u62a4MariaDB\u5b89\u5168\u914d\u7f6e\u3002<\/p>\n

\u5b89\u88c5MariaDB<\/strong><\/span><\/div>\n
\r\nwuxiangping@linuxcool:~$ sudo apt update\r\nwuxiangping@linuxcool:~$ sudo apt install mariadb-server\r\n<\/pre>\n

\u5b89\u88c5\u5b8c\u6210\u540e\uff0cMariaDB\u670d\u52a1\u5c06\u81ea\u52a8\u542f\u52a8\u3002<\/p>\n

\u9a8c\u8bc1\u6570\u636e\u5e93\u670d\u52a1\u5668\u8fd0\u884c\u72b6\u6001<\/strong><\/span><\/div>\n
\r\nwuxiangping@linuxcool:~$ sudo systemctl status mariadb.service\r\n<\/pre>\n

\"\"<\/p>\n

\u67e5\u770b\u6570\u636e\u5e93\u7248\u672c\u53f7<\/strong><\/span><\/div>\n
\r\nwuxiangping@linuxcool:~$ mysql --version\r\nmysql  Ver 15.1 Distrib 10.1.44-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2\r\n<\/pre>\n

\"\"<\/p>\n

MariaDB\u5b89\u5168\u914d\u7f6e\uff0c\u521d\u59cb\u5316\u6570\u636e<\/strong><\/span><\/div>\n

MariaDB\u670d\u52a1\u5668\u8f6f\u4ef6\u5305\u81ea\u5e26\u4e00\u4e2a\u540d\u4e3amysql_secure_installation\u7684\u811a\u672c\uff0c\u53ef\u4ee5\u8f7b\u677e\u63d0\u9ad8\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u3002<\/p>\n

\r\nwuxiangping@linuxcool:~$ sudo mysql_secure_installation\r\n\r\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\r\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\r\n\r\nIn order to log into MariaDB to secure it, we'll need the current\r\npassword for the root user.  If you've just installed MariaDB, and\r\nyou haven't set the root password yet, the password will be blank,\r\nso you should just press enter here.\r\n\r\nEnter current password for root (enter for none):\r\nOK, successfully used password, moving on...\r\n\r\nSetting the root password ensures that nobody can log into the MariaDB\r\nroot user without the proper authorisation.\r\n\r\nYou already have a root password set, so you can safely answer 'n'.\r\n\r\nChange the root password? [Y\/n] y\r\nNew password: \r\nRe-enter new password: \r\nPassword updated successfully!\r\nReloading privilege tables..\r\n ... Success!\r\n\r\n\r\nBy default, a MariaDB installation has an anonymous user, allowing anyone\r\nto log into MariaDB without having to have a user account created for\r\nthem.  This is intended only for testing, and to make the installation\r\ngo a bit smoother.  You should remove them before moving into a\r\nproduction environment.\r\n\r\nRemove anonymous users? [Y\/n] y\r\n ... Success!\r\n\r\nNormally, root should only be allowed to connect from 'localhost'.  This\r\nensures that someone cannot guess at the root password from the network.\r\n\r\nDisallow root login remotely? [Y\/n] y\r\n ... Success!\r\n\r\nBy default, MariaDB comes with a database named 'test' that anyone can\r\naccess.  This is also intended only for testing, and should be removed\r\nbefore moving into a production environment.\r\n\r\nRemove test database and access to it? [Y\/n] y\r\n - Dropping test database...\r\n ... Success!\r\n - Removing privileges on test database...\r\n ... Success!\r\n\r\nReloading the privilege tables will ensure that all changes made so far\r\nwill take effect immediately.\r\n\r\nReload privilege tables now? [Y\/n] y\r\n ... Success!\r\n\r\nCleaning up...\r\n\r\nAll done!  If you've completed all of the above steps, your MariaDB\r\ninstallation should now be secure.\r\n\r\nThanks for using MariaDB!\r\n<\/pre>\n

\"\"<\/p>\n

\u672c\u5730root\u7528\u6237\u767b\u5f55<\/strong><\/span><\/div>\n

shell\u4e0eMariaDB\u4ea4\u4e92\u64cd\u4f5c\uff0c\u8fd0\u884c\u65f6\u4f1a\u63d0\u793a\u8f93\u5165\u7cfb\u7edf\u7528\u6237\u540d\u7684\u5bc6\u7801<\/p>\n

\r\nwuxiangping@linuxcool:~$ sudo mysql\r\n[sudo] wuxiangping \u7684\u5bc6\u7801\uff1a \r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 49\r\nServer version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.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)]> \r\n<\/pre>\n
\u6388\u6743MariaDB\u6307\u5b9a\u4e3b\u673a\u8fdc\u7a0b\u8bbf\u95ee<\/strong><\/span><\/div>\n

\u9ed8\u8ba4\u76d1\u542c\u7aef\u53e3\u662f127.0.0.1\uff0c\u9700\u8981\u4fee\u6539\u4e3a\u4e3b\u673aIP<\/p>\n

\r\nwuxiangping@linuxcool:~$ sudo vim \/etc\/mysql\/mariadb.conf.d\/50-server.cnf\r\nbind-address=192.168.3.22\r\n<\/pre>\n

\"\"<\/p>\n

\r\nMariaDB [(none)]> use mysql;\r\nReading table information for completion of table and column names\r\nYou can turn off this feature to get a quicker startup with -A\r\n\r\nDatabase changed\r\nMariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.3.8' IDENTIFIED BY 'password' WITH GRANT OPTION;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n\r\nMariaDB [mysql]> flush privileges;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n\r\nMariaDB [mysql]> select host, user from user;\r\n<\/pre>\n

\"\"<\/p>\n

\u91cd\u542fmariadb\u670d\u52a1<\/p>\n

\r\nwuxiangping@linuxcool:~$ sudo systemctl restart mariadb.service\r\n<\/pre>\n
\u8fdc\u7a0b\u4e3b\u673a\u8fde\u63a5\u6d4b\u8bd5<\/strong><\/span><\/div>\n

\"\"<\/p>\n

\"\"<\/p>\n

\u8fde\u63a5\u6210\u529f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

MariaDB\u7531MySQL\u7684\u539f\u59cb\u5f00\u53d1\u8005\u548c\u5f00\u6e90\u793e\u533a\u5f00\u53d1\u548c\u7ef4\u62a4,\u8fd9\u91cc\u6211\u4eec\u6765\u4ecb\u7ecd\u5982\u4f55\u5728Ubuntu 20.04\u4e0a\u5b89\u88c5 […]<\/p>\n","protected":false},"author":668,"featured_media":192086,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-192085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=192085"}],"version-history":[{"count":12,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192085\/revisions"}],"predecessor-version":[{"id":194411,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192085\/revisions\/194411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/192086"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=192085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=192085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=192085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}