{"id":4009,"date":"2020-02-12T08:24:56","date_gmt":"2020-02-12T01:24:56","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=4009"},"modified":"2020-03-06T16:13:09","modified_gmt":"2020-03-06T09:13:09","slug":"huong-dan-cai-dat-mariadb-tren-centos7","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/huong-dan-cai-dat-mariadb-tren-centos7\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t MariaDB tr\u00ean CentOS7"},"content":{"rendered":"<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/imSJynz9cfk\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Tr\u01b0\u1edbc khi c\u00e0i \u0111\u1eb7t Mariadb b\u1ea1n c\u1ea7n ch\u00fa \u00fd l\u00e0 h\u1ec7 \u0111i\u1ec1u h\u00e0nh ch\u01b0a c\u00f3 c\u00e0i \u0111\u1eb7t Mysql ho\u1eb7c Mariadb n\u00e0o tr\u01b0\u1edbc \u0111\u00f3 \u0111\u1ec3 tr\u00e1nh vi\u1ec7c m\u1ea5t d\u1eef li\u1ec7u ho\u1eb7c g\u00e2y ra l\u1ed7i sau khi c\u00e0i \u0111\u1eb7t.<\/p>\n<p>Trong h\u01b0\u1edbng d\u1eabn n\u00e0y m\u00ecnh s\u1ebd h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t MariaDB tr\u00ean CentOS7 v\u1edbi yum t\u1eeb repo MariaDB.<\/p>\n<p>B\u1ea1n c\u00f3 th\u1ec3 c\u1ea5u h\u00ecnh c\u00e1c repo d\u1ef1a theo h\u1ec7 \u0111i\u1ec1u h\u00e0nh m\u00e0 b\u1ea1n s\u1eed d\u1ee5ng, MariaDB c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t tr\u00ean nhi\u1ec1u h\u1ec7 \u0111i\u1ec1u h\u00e0nh kh\u00e1c nhau kh\u00f4ng ph\u1ea3i ch\u1ec9 c\u00e0i \u0111\u01b0\u1ee3c tr\u00ean CentOS7.<\/p>\n<p>Link t\u1ea1i \u0111\u00e2y: <a href=\"https:\/\/downloads.mariadb.org\/mariadb\/repositories\/#distro=CentOS&amp;distro_release=centos7-amd64--centos7&amp;mirror=rise&amp;version=10.3\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/downloads.mariadb.org\/mariadb\/repositories\/#distro=CentOS&amp;distro_release=centos7-amd64&#8211;centos7&amp;mirror=rise&amp;version=10.3<\/a><\/p>\n<p>Ho\u1eb7c c\u00f3 c\u00e1ch kh\u00e1c \u0111\u01a1n gi\u1ea3i h\u01a1n l\u00e0 s\u1eed d\u1ee5ng t\u1eadp l\u1ec7nh c\u1ea5u h\u00ecnh repo c\u1ee7a MariaDB b\u1eb1ng c\u00e1ch ssh v\u00e0o vps v\u00e0 ch\u1ea1y l\u1ec7nh sau:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">curl -sS https:\/\/downloads.mariadb.com\/MariaDB\/mariadb_repo_setup | bash -s -- --mariadb-server-version=\"mariadb-10.4\"<\/pre>\n<p>Trong \u0111\u00f3 c\u00e1c phi\u00ean b\u1ea3n MariaDB sau \u0111\u00e2y hi\u1ec7n \u0111ang \u0111\u01b0\u1ee3c h\u1ed7 tr\u1ee3:<\/p>\n<ul>\n<li>mariadb-5.5<\/li>\n<li>mariadb-10.0<\/li>\n<li>mariadb-10.1<\/li>\n<li>mariadb-10.2<\/li>\n<li>mariadb-10.3<\/li>\n<li>mariadb-10.4<\/li>\n<\/ul>\n<p><a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.19.03.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4011\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.19.03.png\" alt=\"\" width=\"1952\" height=\"856\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.19.03.png 1952w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.19.03-300x132.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.19.03-1024x449.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.19.03-768x337.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.19.03-1536x674.png 1536w\" sizes=\"(max-width: 1952px) 100vw, 1952px\" \/><\/a><\/p>\n<p>Sau khi c\u00e0i \u0111\u1eb7t repo ho\u00e0n t\u1ea5t l\u00e0 \u0111\u00e3 c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t Mariadb, ch\u1ea1y l\u1ec7nh sau tr\u00ean SSH:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">yum install MariaDB-server MariaDB-client -y<\/pre>\n<p><a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.27.55.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4012\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.27.55.png\" alt=\"\" width=\"1952\" height=\"1264\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.27.55.png 1952w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.27.55-300x194.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.27.55-1024x663.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.27.55-768x497.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.27.55-1536x995.png 1536w\" sizes=\"(max-width: 1952px) 100vw, 1952px\" \/><\/a><\/p>\n<p>sau khi nh\u1eadn \u0111\u01b0\u1ee3c th\u00f4ng b\u00e1o c\u00e0i \u0111\u1eb7t Complete!\u00a0 ch\u00fang ta s\u1ebd kh\u1edfi \u0111\u1ed9ng MariaDB server v\u00e0 b\u1eaft \u0111\u1ea7u thi\u1ebfu l\u1eadp b\u1ea3o m\u1eadt\u00a0 cho Mariadb b\u1eb1ng l\u1ec7nh sau:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># cho ph\u00e9p MariaDB kh\u1edfi \u0111\u1ed9ng khi reboot server\r\nsystemctl enable mariadb\r\n\r\n# Kh\u1edfi \u0111\u1ed9ng Mariadb\r\nsystemctl start mariadb\r\n\r\n# Thi\u1ebft l\u1eadp b\u1ea3o m\u1eadt cho Mariadb\r\nmysql_secure_installation<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.40.39.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4013\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.40.39.png\" alt=\"\" width=\"1114\" height=\"1890\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.40.39.png 1114w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.40.39-177x300.png 177w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.40.39-604x1024.png 604w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.40.39-768x1303.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.40.39-905x1536.png 905w\" sizes=\"(max-width: 1114px) 100vw, 1114px\" \/><\/a><\/p>\n<p>C\u00e1c thi\u1ebft l\u1eadp b\u1ea1n c\u00f3 th\u1ec3 tham kh\u1ea3o nh\u01b0 sau:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">root@mariadb ~]# 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): Nh\u1ea5n enter\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\nSet root password? [Y\/n] y\r\nNew password: Nh\u1eadp m\u1eadt kh\u1ea9u\r\nRe-enter new password: Nh\u1eadp l\u1ea1i m\u1eadt kh\u1ea9u\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!<\/pre>\n<p>&nbsp;<\/p>\n<p>Nh\u01b0 v\u1eady l\u00e0 \u0111\u00e3 c\u00e0i \u0111\u1eb7t ho\u00e0n t\u1ea5t, b\u1ea1n c\u00f3 th\u1ec3 d\u00f9ng l\u1ec7nh sau \u0111\u1ec3 truy c\u1eadp MariaDB \u0111\u1ec3 ki\u1ec3m tra ho\u1ea1t \u0111\u1ed9ng<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">mysql -u root -p\r\n\r\n# sau khi g\u00f5 l\u1ec7nh tr\u00ean h\u1ec7 th\u1ed1ng s\u1ebd y\u00eau c\u1ea7u b\u1ea1n nh\u1eadp m\u1eadt kh\u1ea9u root Mariadb m\u00e0 b\u1ea1n \u0111\u00e3 kh\u1edfi t\u1ea1o trong ph\u1ea7n mysql_secure_installation tr\u01b0\u1edbc \u0111\u00f3.<\/pre>\n<p><a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.47.35.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4015\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.47.35.png\" alt=\"\" width=\"1896\" height=\"652\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.47.35.png 1896w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.47.35-300x103.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.47.35-1024x352.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.47.35-768x264.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-11-at-15.47.35-1536x528.png 1536w\" sizes=\"(max-width: 1896px) 100vw, 1896px\" \/><\/a><\/p>\n<p>C\u00f3 1 \u0111i\u1ec1u l\u00e0 m\u1ed7i l\u1ea7n \u0111\u0103ng nh\u1eadp v\u00e0o MariaDB b\u1ea1n s\u1ebd c\u1ea7n nh\u1eadp user v\u00e0 m\u1eadt kh\u1ea9u. N\u1ebfu b\u1ea1n l\u00e0 ng\u01b0\u1eddi qu\u1ea3n tr\u1ecb duy nh\u1ea5t c\u1ee7a h\u1ec7 th\u1ed1ng server b\u1ea1n c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n\u00a0 chu\u1ed7i l\u1ec7nh sau \u0111\u1ec3 t\u1ea1o file m\u00f4i tr\u01b0\u1eddng l\u01b0u tr\u1eef m\u1eadt kh\u1ea9u v\u00e0 t\u00e0i kho\u1ea3n Mariadb \u0111\u1ec3 \u0111\u0103ng nh\u1eadp thu\u1eadn ti\u1ec7n<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># Di chuy\u1ec3n \u0111\u1ebfn th\u01b0 m\u1ee5c g\u1ed1c user \u0111ang ssh\r\ncd ~\r\n\r\n# t\u1ea1o file l\u01b0u th\u00f4ng tin t\u00e0i kho\u1ea3n MariaDB\r\ntouch .my.cnf\r\n\r\n# th\u00eam th\u00f4ng tin t\u00e0i kho\u1ea3n MariaDB v\u00e0o file v\u1eeba t\u1ea1o (ch\u00fa \u00fd thanh yourpassword b\u1eb1ng m\u1eadt kh\u1ea9u  c\u1ee7a b\u1ea1n)\r\necho -e \"[client] \\nuser=root \\npassword=yourpassword \" &gt;&gt; .my.cnf\r\n<\/pre>\n<p>Sau khi ho\u00e0n t\u1ea5t b\u1ea1n ch\u1ec9 c\u1ea7n g\u00f5 l\u1ec7nh mysql \u0111\u1ec3 truy c\u1eadp v\u00e0o MariaDb<\/p>\n<p><a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-12-at-08.23.58.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4019\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-12-at-08.23.58.png\" alt=\"\" width=\"837\" height=\"309\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-12-at-08.23.58.png 837w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-12-at-08.23.58-300x111.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-02-12-at-08.23.58-768x284.png 768w\" sizes=\"(max-width: 837px) 100vw, 837px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tr\u01b0\u1edbc khi c\u00e0i \u0111\u1eb7t Mariadb b\u1ea1n c\u1ea7n ch\u00fa \u00fd l\u00e0 h\u1ec7 \u0111i\u1ec1u h\u00e0nh ch\u01b0a c\u00f3 c\u00e0i \u0111\u1eb7t Mysql ho\u1eb7c Mariadb n\u00e0o tr\u01b0\u1edbc \u0111\u00f3 \u0111\u1ec3 tr\u00e1nh vi\u1ec7c m\u1ea5t d\u1eef li\u1ec7u ho\u1eb7c g\u00e2y ra l\u1ed7i sau khi c\u00e0i \u0111\u1eb7t. Trong h\u01b0\u1edbng d\u1eabn n\u00e0y m\u00ecnh s\u1ebd h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t MariaDB tr\u00ean CentOS7 v\u1edbi yum t\u1eeb repo MariaDB. [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[5156],"class_list":["post-4009","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-mariadb"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=4009"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4009\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=4009"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=4009"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=4009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}