{"id":20477,"date":"2021-02-12T23:38:38","date_gmt":"2021-02-12T15:38:38","guid":{"rendered":"http:\/\/www.idc.net\/help\/20477\/"},"modified":"2022-04-29T14:34:14","modified_gmt":"2022-04-29T06:34:14","slug":"ubuntu%e4%b8%8b%e5%ae%89%e8%a3%85mariadb%e5%85%b7%e4%bd%93%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/20477\/","title":{"rendered":"Ubuntu\u4e0b\u5b89\u88c5MariaDB\u5177\u4f53\u6b65\u9aa4"},"content":{"rendered":"<div class=\"idc_table\">\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">MariaDB\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u662f MySQL \u7684\u4e00\u4e2a\u5206\u652f\uff0c\u4e3b\u8981\u7531\u5f00\u6e90\u793e\u533a\u5728\u7ef4\u62a4\uff0c\u91c7\u7528GPL\u6388\u6743\u8bb8\u53ef MariaDB\u7684\u76ee\u7684\u662f\u5b8c\u5168\u517c\u5bb9MySQL\uff0c\u5305\u62ecAPI\u548c\u547d\u4ee4\u884c\uff0c\u4f7f\u4e4b\u80fd\u8f7b\u677e\u6210\u4e3aMySQL\u7684\u4ee3\u66ff\u54c1\uff0c\u4e0b\u9762\u4e3a\u5927\u5bb6\u5206\u4eab\u4e00\u4e0bUbuntu\u4e0b\u5b89\u88c5MariaDB\u5177\u4f53\u6b65\u9aa4\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294944eaada739a6d932.jpg\">  <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u5b89\u88c5MariaDB<\/span><\/h3>\n<pre><code>wuxiangping@linuxcool:~$&nbsp;sudo&nbsp;apt&nbsp;update\r\nwuxiangping@linuxcool:~$&nbsp;sudo&nbsp;apt&nbsp;install&nbsp;mariadb-server\r\n<\/code><\/pre>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u5b89\u88c5\u5b8c\u6210\u540e\uff0cMariaDB\u670d\u52a1\u5c06\u81ea\u52a8\u542f\u52a8\u3002<\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u9a8c\u8bc1\u6570\u636e\u5e93\u670d\u52a1\u5668\u8fd0\u884c\u72b6\u6001<\/span><\/h3>\n<pre><code>wuxiangping@linuxcool:~$&nbsp;sudo&nbsp;systemctl&nbsp;status&nbsp;mariadb.service\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294744eaada739a6d587.png\" class=\"aligncenter\">  \u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB   <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u67e5\u770b\u6570\u636e\u5e93\u7248\u672c\u53f7<\/span><\/h3>\n<pre><code>wuxiangping@linuxcool:~$&nbsp;mysql&nbsp;--version\r\nmysql&nbsp;&nbsp;Ver&nbsp;15.1&nbsp;Distrib&nbsp;10.1.44-MariaDB,&nbsp;<span style=\"color: #569cd6;line-height: 26px\">for<\/span>&nbsp;debian-linux-gnu&nbsp;(x86_64)&nbsp;using&nbsp;readline&nbsp;5.2\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294944eaada739a6d9a5.png\" class=\"aligncenter\">  \u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB   <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">MariaDB\u5b89\u5168\u914d\u7f6e\uff0c\u521d\u59cb\u5316\u6570\u636e<\/span><\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">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<pre><code>wuxiangping@linuxcool:~$&nbsp;sudo&nbsp;mysql_secure_installation\r\n\r\nNOTE:&nbsp;RUNNING&nbsp;ALL&nbsp;PARTS&nbsp;OF&nbsp;THIS&nbsp;SCRIPT&nbsp;IS&nbsp;RECOMMENDED&nbsp;FOR&nbsp;ALL&nbsp;MariaDB\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SERVERS&nbsp;IN&nbsp;PRODUCTION&nbsp;USE!&nbsp;&nbsp;PLEASE&nbsp;READ&nbsp;EACH&nbsp;STEP&nbsp;CAREFULLY!\r\n\r\nIn&nbsp;order&nbsp;to&nbsp;<span style=\"color: #4ec9b0;line-height: 26px\">log<\/span>&nbsp;into&nbsp;MariaDB&nbsp;to&nbsp;secure&nbsp;it,&nbsp;we<span style=\"color: #d69d85;line-height: 26px\">'ll&nbsp;need&nbsp;the&nbsp;current password&nbsp;for&nbsp;the&nbsp;root&nbsp;user.&nbsp;&nbsp;If&nbsp;you'<\/span>ve&nbsp;just&nbsp;installed&nbsp;MariaDB,&nbsp;and\r\nyou&nbsp;haven<span style=\"color: #d69d85;line-height: 26px\">'t&nbsp;set&nbsp;the&nbsp;root&nbsp;password&nbsp;yet,&nbsp;the&nbsp;password&nbsp;will&nbsp;be&nbsp;blank, so&nbsp;you&nbsp;should&nbsp;just&nbsp;press&nbsp;enter&nbsp;here. Enter&nbsp;current&nbsp;password&nbsp;for&nbsp;root&nbsp;(enter&nbsp;for&nbsp;none): OK,&nbsp;successfully&nbsp;used&nbsp;password,&nbsp;moving&nbsp;on... Setting&nbsp;the&nbsp;root&nbsp;password&nbsp;ensures&nbsp;that&nbsp;nobody&nbsp;can&nbsp;log&nbsp;into&nbsp;the&nbsp;MariaDB root&nbsp;user&nbsp;without&nbsp;the&nbsp;proper&nbsp;authorisation. You&nbsp;already&nbsp;have&nbsp;a&nbsp;root&nbsp;password&nbsp;set,&nbsp;so&nbsp;you&nbsp;can&nbsp;safely&nbsp;answer&nbsp;'<\/span>n<span style=\"color: #d69d85;line-height: 26px\">'. Change&nbsp;the&nbsp;root&nbsp;password?&nbsp;[Y\/n]&nbsp;y New&nbsp;password: Re-enter&nbsp;new&nbsp;password: Password&nbsp;updated&nbsp;successfully! Reloading&nbsp;privilege&nbsp;tables.. ...&nbsp;Success! By&nbsp;default,&nbsp;a&nbsp;MariaDB&nbsp;installation&nbsp;has&nbsp;an&nbsp;anonymous&nbsp;user,&nbsp;allowing&nbsp;anyone to&nbsp;log&nbsp;into&nbsp;MariaDB&nbsp;without&nbsp;having&nbsp;to&nbsp;have&nbsp;a&nbsp;user&nbsp;account&nbsp;created&nbsp;for them.&nbsp;&nbsp;This&nbsp;is&nbsp;intended&nbsp;only&nbsp;for&nbsp;testing,&nbsp;and&nbsp;to&nbsp;make&nbsp;the&nbsp;installation go&nbsp;a&nbsp;bit&nbsp;smoother.&nbsp;&nbsp;You&nbsp;should&nbsp;remove&nbsp;them&nbsp;before&nbsp;moving&nbsp;into&nbsp;a production&nbsp;environment. Remove&nbsp;anonymous&nbsp;users?&nbsp;[Y\/n]&nbsp;y ...&nbsp;Success! Normally,&nbsp;root&nbsp;should&nbsp;only&nbsp;be&nbsp;allowed&nbsp;to&nbsp;connect&nbsp;from&nbsp;'<\/span>localhost<span style=\"color: #d69d85;line-height: 26px\">'.&nbsp;&nbsp;This ensures&nbsp;that&nbsp;someone&nbsp;cannot&nbsp;guess&nbsp;at&nbsp;the&nbsp;root&nbsp;password&nbsp;from&nbsp;the&nbsp;network. Disallow&nbsp;root&nbsp;login&nbsp;remotely?&nbsp;[Y\/n]&nbsp;y ...&nbsp;Success! By&nbsp;default,&nbsp;MariaDB&nbsp;comes&nbsp;with&nbsp;a&nbsp;database&nbsp;named&nbsp;'<\/span><span style=\"color: #4ec9b0;line-height: 26px\">test<\/span><span style=\"color: #d69d85;line-height: 26px\">'&nbsp;that&nbsp;anyone&nbsp;can access.&nbsp;&nbsp;This&nbsp;is&nbsp;also&nbsp;intended&nbsp;only&nbsp;for&nbsp;testing,&nbsp;and&nbsp;should&nbsp;be&nbsp;removed before&nbsp;moving&nbsp;into&nbsp;a&nbsp;production&nbsp;environment. Remove&nbsp;test&nbsp;database&nbsp;and&nbsp;access&nbsp;to&nbsp;it?&nbsp;[Y\/n]&nbsp;y -&nbsp;Dropping&nbsp;test&nbsp;database... ...&nbsp;Success! -&nbsp;Removing&nbsp;privileges&nbsp;on&nbsp;test&nbsp;database... ...&nbsp;Success! Reloading&nbsp;the&nbsp;privilege&nbsp;tables&nbsp;will&nbsp;ensure&nbsp;that&nbsp;all&nbsp;changes&nbsp;made&nbsp;so&nbsp;far will&nbsp;take&nbsp;effect&nbsp;immediately. Reload&nbsp;privilege&nbsp;tables&nbsp;now?&nbsp;[Y\/n]&nbsp;y ...&nbsp;Success! Cleaning&nbsp;up... All&nbsp;done!&nbsp;&nbsp;If&nbsp;you'<\/span>ve&nbsp;completed&nbsp;all&nbsp;of&nbsp;the&nbsp;above&nbsp;steps,&nbsp;your&nbsp;MariaDB\r\ninstallation&nbsp;should&nbsp;now&nbsp;be&nbsp;secure.\r\n\r\nThanks&nbsp;<span style=\"color: #569cd6;line-height: 26px\">for<\/span>&nbsp;using&nbsp;MariaDB!\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294a44eaada739a6da49.png\" class=\"aligncenter\">  \u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB   <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u672c\u5730root\u7528\u6237\u767b\u5f55<\/span><\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">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<pre><code>wuxiangping@linuxcool:~$&nbsp;sudo&nbsp;mysql\r\n[sudo]&nbsp;wuxiangping&nbsp;\u7684\u5bc6\u7801\uff1a\r\nWelcome&nbsp;to&nbsp;the&nbsp;MariaDB&nbsp;monitor.&nbsp;&nbsp;Commands&nbsp;end&nbsp;with&nbsp;;&nbsp;or&nbsp;\\g.\r\nYour&nbsp;MariaDB&nbsp;connection&nbsp;id&nbsp;is&nbsp;49\r\nServer&nbsp;version:&nbsp;10.1.44-MariaDB-0ubuntu0.18.04.1&nbsp;Ubuntu&nbsp;18.04\r\n\r\nCopyright&nbsp;(c)&nbsp;2000,&nbsp;2018,&nbsp;Oracle,&nbsp;MariaDB&nbsp;Corporation&nbsp;Ab&nbsp;and&nbsp;others.\r\n\r\nType&nbsp;<span style=\"color: #d69d85;line-height: 26px\">'help;'<\/span>&nbsp;or&nbsp;<span style=\"color: #d69d85;line-height: 26px\">'\\h'<\/span>&nbsp;<span style=\"color: #569cd6;line-height: 26px\">for<\/span>&nbsp;<span style=\"color: #4ec9b0;line-height: 26px\">help<\/span>.&nbsp;Type&nbsp;<span style=\"color: #d69d85;line-height: 26px\">'\\c'<\/span>&nbsp;to&nbsp;clear&nbsp;the&nbsp;current&nbsp;input&nbsp;statement.\r\n\r\nMariaDB&nbsp;[(none)]&gt;\r\n<\/code><\/pre>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u6388\u6743MariaDB\u6307\u5b9a\u4e3b\u673a\u8fdc\u7a0b\u8bbf\u95ee<\/span><\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u9ed8\u8ba4\u76d1\u542c\u7aef\u53e3\u662f127.0.0.1\uff0c\u9700\u8981\u4fee\u6539\u4e3a\u4e3b\u673aIP<\/p>\n<pre><code>wuxiangping@linuxcool:~$&nbsp;sudo&nbsp;vim&nbsp;\/etc\/mysql\/mariadb.conf.d\/50-server.cnf\r\n<span style=\"color: #4ec9b0;line-height: 26px\">bind<\/span>-address=192.168.3.22\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294944eaada739a6d892.png\" class=\"aligncenter\">  \u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB   <\/p>\n<pre><code>MariaDB&nbsp;[(none)]&gt;&nbsp;use&nbsp;mysql;\r\nReading&nbsp;table&nbsp;information&nbsp;<span style=\"color: #569cd6;line-height: 26px\">for<\/span>&nbsp;completion&nbsp;of&nbsp;table&nbsp;and&nbsp;column&nbsp;names\r\nYou&nbsp;can&nbsp;turn&nbsp;off&nbsp;this&nbsp;feature&nbsp;to&nbsp;get&nbsp;a&nbsp;quicker&nbsp;startup&nbsp;with&nbsp;-A\r\n\r\nDatabase&nbsp;changed\r\nMariaDB&nbsp;[mysql]&gt;&nbsp;GRANT&nbsp;ALL&nbsp;PRIVILEGES&nbsp;ON&nbsp;*.*&nbsp;TO&nbsp;<span style=\"color: #d69d85;line-height: 26px\">'root'<\/span>@<span style=\"color: #d69d85;line-height: 26px\">'192.168.3.8'<\/span>&nbsp;IDENTIFIED&nbsp;BY&nbsp;<span style=\"color: #d69d85;line-height: 26px\">'password'<\/span>&nbsp;WITH&nbsp;GRANT&nbsp;OPTION;\r\nQuery&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.00&nbsp;sec)\r\n\r\nMariaDB&nbsp;[mysql]&gt;&nbsp;flush&nbsp;privileges;\r\nQuery&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.00&nbsp;sec)\r\n\r\nMariaDB&nbsp;[mysql]&gt;&nbsp;select&nbsp;host,&nbsp;user&nbsp;from&nbsp;user;\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294844eaada739a6d63c.png\" class=\"aligncenter\">  \u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB   <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u91cd\u542fmariadb\u670d\u52a1<\/p>\n<pre><code>wuxiangping@linuxcool:~$&nbsp;sudo&nbsp;systemctl&nbsp;restart&nbsp;mariadb.service\r\n<\/code><\/pre>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u8fdc\u7a0b\u4e3b\u673a\u8fde\u63a5\u6d4b\u8bd5<\/span><\/h3>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294b44eaada739a6dc87.png\" class=\"aligncenter\">  \u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB<br \/>\n<img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/6137294744eaada739a6d423.png\" class=\"aligncenter\">  \u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB\u5728Ubuntu\u4e0a\u5b89\u88c5MariaDB   <\/p>\n","protected":false},"excerpt":{"rendered":"<p>MariaDB\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u662f MySQL \u7684\u4e00\u4e2a\u5206\u652f\uff0c\u4e3b\u8981\u7531\u5f00\u6e90\u793e\u533a\u5728\u7ef4\u62a4\uff0c\u91c7\u7528GPL\u6388\u6743\u8bb8\u53ef MariaD [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":20478,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,28],"tags":[],"class_list":["post-20477","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/20477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=20477"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/20477\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/20478"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=20477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=20477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=20477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}