{"id":314,"date":"2022-04-01T22:16:00","date_gmt":"2022-04-01T15:16:00","guid":{"rendered":"http:\/\/congdong.longvan.net\/?p=314"},"modified":"2022-11-03T11:07:57","modified_gmt":"2022-11-03T04:07:57","slug":"huong-dan-cai-phpmyadmin-tren-linux","status":"publish","type":"post","link":"https:\/\/longvan.net\/cong-dong\/huong-dan-cai-phpmyadmin-tren-linux\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn c\u00e0i phpmyadmin tr\u00ean Linux"},"content":{"rendered":"<div>\n<h5><strong>I. phpMyAdmin<\/strong><\/h5>\n<p>PhpMyAdmin l\u00e0 ph\u1ea7n m\u1ec1m m\u00e3 ngu\u1ed3n m\u1edf \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng ng\u00f4n ng\u1eef PHP gi\u00fap qu\u1ea3n tr\u1ecb c\u1edf s\u1edf d\u1eef li\u1ec7u MySQL th\u00f4ng qua giao di\u1ec7n web.<\/p>\n<p>M\u1ed9t s\u1ed1 t\u00ednh n\u0103ng chung th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng tr\u00ean phpMyAdmin:<\/p>\n<ul>\n<li>Qu\u1ea3n l\u00fd user(ng\u01b0\u1eddi d\u00f9ng): th\u00eam, x\u00f3a, s\u1eeda(ph\u00e2n quy\u1ec1n).<\/li>\n<li>Qu\u1ea3n l\u00fd c\u01a1 s\u1edf d\u1eef li\u1ec7u: t\u1ea1o m\u1edbi, x\u00f3a, s\u1eeda, th\u00eam b\u1ea3ng, h\u00e0ng, tr\u01b0\u1eddng, t\u00ecm ki\u1ebfm \u0111\u1ed1i t\u01b0\u1ee3ng.<\/li>\n<li>Nh\u1eadp xu\u1ea5t d\u1eef li\u1ec7u(Import\/Export): h\u1ed7 tr\u1ee3 c\u00e1c \u0111\u1ecbnh d\u1ea1ng SQL, XML v\u00e0 CSV.<\/li>\n<li>Th\u1ef1c hi\u1ec7n c\u00e1c truy v\u1ea5n MySQL, gi\u00e1m s\u00e1t qu\u00e1 tr\u00ecnh v\u00e0 theo d\u00f5i.<\/li>\n<li>Sao l\u01b0u v\u00e0 kh\u00f4i ph\u1ee5c(Backup\/Restore): Thao t\u00e1c th\u1ee7 c\u00f4ng.<\/li>\n<\/ul>\n<h5><strong>II. C\u00e0i \u0111\u1eb7t phpMyAdmin<\/strong><\/h5>\n<p>Sau \u0111\u00e2y Long V\u00e2n s\u1ebd h\u01b0\u1edbng d\u1eabn c\u00e1ch c\u00e0i phpmyadmin tr\u00ean server linux:<\/p>\n<ol>\n<li><strong>\u00c1p d\u1ee5ng cho server CentOS, ch\u1ea1y web server l\u00e0 apache.<br \/>\n<\/strong>Y\u00eau c\u1ea7u: server \u0111\u00e3 c\u00e0i webservice apache, php, mysql ho\u1eb7c mariadb<\/p>\n<ul>\n<li><strong>B\u01b0\u1edbc 1<\/strong>: SSH v\u00e0o server ch\u1ea1y l\u1ea7n l\u01b0\u1ee3t c\u00e1c l\u1ec7nh\n<pre><em># sudo yum install epel-release -y<\/em>\n<em><em># sudo yum install phpmyadmin -y<\/em><\/em><\/pre>\n<\/li>\n<li><strong>B\u01b0\u1edbc 2:<\/strong> Truy c\u1eadp v\u00e0o \u0111\u01b0\u1eddng d\u1eabn vi \/etc\/httpd\/conf.d\/phpMyAdmin.conf v\u00e0 \u0111i\u1ec1u ch\u1ec9nh nh\u01b0 h\u00ecnh.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1417\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821747904.png\" alt=\"\" width=\"620\" height=\"418\" \/><\/li>\n<li><strong>B\u01b0\u1edbc 3<\/strong>: Kh\u1edfi \u0111\u1ed9ng l\u1ea1i service apache, mysql b\u1eb1ng l\u1ec7nh sau:\n<pre><em># systemctl restart httpd &amp;&amp; systemctl restart mysqld\n<\/em><\/pre>\n<\/li>\n<li>Truy c\u1eadp phpmyadmin v\u1edbi \u0111\u01b0\u1eddng d\u1eabn http:\/\/[ip-address]\/phpmyadmin v\u00e0 login v\u00e0o<br \/>\n<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821759838.png\" alt=\"image-1632821759838.png\" \/><\/li>\n<\/ul>\n<\/li>\n<li><strong>\u00c1p d\u1ee5ng cho server CentOS, ch\u1ea1y web server l\u00e0 nginx.<br \/>\n<\/strong>Y\u00eau c\u1ea7u: server \u0111\u00e3 c\u00e0i webservice apache, php v\u00e0 c\u00e1c extension li\u00ean quan bao g\u1ed3m php-mysqli, mysql.<\/p>\n<ul>\n<li><strong>B\u01b0\u1edbc 1<\/strong>: K\u1ebft n\u1ed1i ssh v\u00e0o server v\u00e0 ch\u1ea1y c\u00e1c l\u1ec7nh:\n<pre><em># yum install phpmyadmin \u2013ycd \/usr\/share<\/em>\n<em># wget https:\/\/files.phpmyadmin.net\/phpMyAdmin\/5.0.2\/phpMyAdmin-5.0.2-all-languages.zip\u00a0 \u00a0 (ngo\u00e0i ra \u0111\u00fang ta c\u00f3 th\u1ec3 t\u00ecm version kh\u00e1c t\u1ea1i web https:\/\/www.phpmyadmin.net\/files\/ theo \u0111\u00fang nhu c\u1ea7u m\u00e0 m\u00ecnh s\u1eed d\u1ee5ng)\u00a0 \u00a0\u00a0<\/em>\n<em># unzip phpMyAdmin-5.0.2-all-languages.zip<\/em>\n<em># mv phpMyAdmin-5.0.2-all-languages phpMyAdmin<\/em>\n<em># rm -rf phpMyAdmin-5.0.2-all-languages.zip<\/em>\n<em># rm -rf \/usr\/share\/phpMyAdmin\/setup<\/em>\n<em><em># ln -s \/usr\/share\/phpMyAdmin \/usr\/share\/nginx\/html\/phpmyadmin<\/em><\/em><\/pre>\n<\/li>\n<li><strong>B\u01b0\u1edbc 2<\/strong>: C\u1ea5u h\u00ecnh phpMyAdmin:<br \/>\nFile c\u1ea5u h\u00ecnh c\u1ee7a PhpMyadmin l\u00e0 file config.inc.php.<\/p>\n<ul>\n<li>Tr\u01b0\u1edbc ti\u00ean c\u00e1c b\u1ea1n c\u1ea7n ch\u1ea1y l\u1ec7nh sau\n<pre><em># mv \/usr\/share\/phpMyAdmin\/config.sample.inc.php \/usr\/share\/phpMyAdmin\/config.inc.php<\/em><\/pre>\n<\/li>\n<li>Ti\u1ebfp theo m\u1edf file \/usr\/share\/phpMyAdmin\/config.inc.php\n<pre><em># vi \/usr\/share\/phpMyAdmin\/config.inc.php<\/em><\/pre>\n<\/li>\n<li>T\u00ecm $cfg[&#8216;blowfish_secret&#8217;] = &#8221;; th\u00eam m\u1ed9t \u0111o\u1ea1n k\u00fd t\u1ef1 b\u1ea5t k\u1ef3 v\u00e0o gi\u1eefa c\u1eb7p nh\u00e1y \u0111\u01a1n. V\u00ed d\u1ee5: <em>$cfg[&#8216;blowfish_secret&#8217;] = &#8216;dsa123e12rwDSADs1few12tr3ewg3s2df3sAD&#8217;;<\/em><img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821791032.png\" alt=\"image-1632821791032.png\" \/><\/li>\n<li>Th\u00eam v\u00e0o cu\u1ed1i file \u0111o\u1ea1n code sau v\u00e0 l\u01b0u l\u1ea1i file config<br \/>\n<em>$cfg[&#8216;TempDir&#8217;] = &#8216;\/usr\/share\/phpMyAdmin\/tmp\/&#8217;;<\/em><br \/>\n<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821801266.png\" alt=\"image-1632821801266.png\" \/><\/li>\n<li>Th\u1ef1c hi\u1ec7n c\u00e1c l\u1ec7nh d\u01b0\u1edbi \u0111\u00e2y:\n<pre><em># mkdir -p \/usr\/share\/phpMyAdmin\/tmp<\/em>\n<em># chown -R nginx:nginx \/usr\/share\/phpMyAdmin\/tmp<\/em>\n<em><em># chmod 777 \/var\/lib\/php\/session\/<\/em><\/em><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>B\u01b0\u1edbc 3:<\/strong> Kh\u1edfi \u0111\u1ed9ng l\u1ea1i service nginx, mysql b\u1eb1ng l\u1ec7nh sau:\n<pre><em><em># systemctl restart nginx &amp;&amp; systemctl restart mysqld<\/em><\/em><\/pre>\n<\/li>\n<li><strong>B\u01b0\u1edbc 4:<\/strong> Truy c\u1eadp phpmyadmin v\u1edbi \u0111\u01b0\u1eddng d\u1eabn http:\/\/[ip-address]\/phpmyadmin v\u00e0 login v\u00e0o<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821813373.png\" alt=\"image-1632821813373.png\" \/><\/li>\n<\/ul>\n<\/li>\n<li><strong>\u00c1p d\u1ee5ng cho server Ubuntu, ch\u1ea1y web server l\u00e0 apache2.<br \/>\n<\/strong>Y\u00eau c\u1ea7u: server \u0111\u00e3 c\u00e0i webservice apache2, php, mysql.<\/p>\n<ul>\n<li><strong>B\u01b0\u1edbc 1:<\/strong> SSH v\u00e0o server ch\u1ea1y l\u1ea7n l\u01b0\u1ee3t c\u00e1c l\u1ec7nh\n<pre><em># apt install phpmyadmin -y<\/em><\/pre>\n<ul>\n<li>Xu\u1ea5t hi\u1ec7n khung h\u00ecnh d\u01b0\u1edbi ch\u1ecdn apache2 v\u00e0 ok \u0111\u1ec3 ti\u1ebfp t\u1ee5c c\u00e0i<br \/>\n<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821830504.png\" alt=\"image-1632821830504.png\" \/><\/li>\n<li>Ch\u1ecdn yes \u0111\u1ec3 ti\u1ebfp t\u1ee5c<br \/>\n<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821837947.png\" alt=\"image-1632821837947.png\" \/><\/li>\n<li>\u0110\u1eb7t passwd ng\u01b0\u1eddi d\u00f9ng phpmyadmin v\u00e0 nh\u1eadp l\u1ea1i passwd x\u00e1c .<br \/>\n<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821845020.png\" alt=\"image-1632821845020.png\" \/><\/li>\n<\/ul>\n<\/li>\n<li><strong>B\u01b0\u1edbc 2:<\/strong> Truy c\u1eadp v\u00e0o mysql\n<ul>\n<li>S\u1eed d\u1ee5ng l\u1ec7nh\n<pre><em># mysql<\/em><\/pre>\n<\/li>\n<li>Sau \u0111\u00f3 d\u00f9ng l\u1ec7nh ki\u1ec3m quy\u1ec1n user phpmyadmin \u0111\u00e3 \u0111\u01b0\u1ee3c c\u1ea5p hay ch\u01b0a.\n<pre><em>&gt; show grants for <\/em><em>phpmyadmin@localhost;<\/em><\/pre>\n<p>Nh\u01b0 h\u00ecnh l\u00e0 user phpmyadmin \u0111\u00e3 \u0111\u01b0\u1ee3c c\u1ea5p full quy\u1ec1n.<br \/>\n<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821865105.png\" alt=\"image-1632821865105.png\" \/><\/li>\n<\/ul>\n<\/li>\n<li><strong>B\u01b0\u1edbc 3:<\/strong> Kh\u1edfi \u0111\u1ed9ng l\u1ea1i service apache2, mysql\n<pre><em><em># systemctl restart apache2 &amp;&amp; systemctl restart mysql<\/em><\/em><\/pre>\n<\/li>\n<li><strong>B\u01b0\u1edbc 4:<\/strong> Truy c\u1eadp phpmyadmin v\u1edbi \u0111\u01b0\u1eddng d\u1eabn http:\/\/[ip-address]\/phpmyadmin v\u00e0 login v\u00e0o:<img decoding=\"async\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/02\/image-1632821875317.png\" alt=\"image-1632821875317.png\" \/><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Nh\u01b0 v\u1eady, Long V\u00e2n \u0111\u00e3 ho\u00e0n th\u00e0nh h\u01b0\u1edbng d\u1eabn Qu\u00fd kh\u00e1ch c\u00e1ch c\u00e0i \u0111\u1eb7t phpmyadmin tr\u00ean h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux. Ch\u00fac Qu\u00fd kh\u00e1ch th\u00e0nh c\u00f4ng !<\/p>\n<\/div>\n<p class=\"wpss_copy\">\n","protected":false},"excerpt":{"rendered":"<p>I. phpMyAdmin PhpMyAdmin l\u00e0 ph\u1ea7n m\u1ec1m m\u00e3 ngu\u1ed3n m\u1edf \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng ng\u00f4n ng\u1eef PHP gi\u00fap qu\u1ea3n tr\u1ecb c\u1edf s\u1edf d\u1eef li\u1ec7u MySQL th\u00f4ng qua giao di\u1ec7n web. M\u1ed9t s\u1ed1 t\u00ednh n\u0103ng chung th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng tr\u00ean phpMyAdmin: Qu\u1ea3n l\u00fd user(ng\u01b0\u1eddi d\u00f9ng): th\u00eam, x\u00f3a, s\u1eeda(ph\u00e2n quy\u1ec1n). Qu\u1ea3n l\u00fd c\u01a1 s\u1edf d\u1eef li\u1ec7u: t\u1ea1o m\u1edbi, [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_oasis_is_in_workflow":0,"_oasis_original":0,"footnotes":""},"categories":[40],"tags":[],"class_list":["post-314","post","type-post","status-publish","format-standard","hentry","category-web-hosting"],"_links":{"self":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/comments?post=314"}],"version-history":[{"count":4,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/314\/revisions"}],"predecessor-version":[{"id":1451,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/314\/revisions\/1451"}],"wp:attachment":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/media?parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/categories?post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/tags?post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}