{"id":79,"date":"2025-11-16T14:18:47","date_gmt":"2025-11-16T14:18:47","guid":{"rendered":"https:\/\/blogs.giamkichsan.com\/?p=79"},"modified":"2025-11-16T14:18:48","modified_gmt":"2025-11-16T14:18:48","slug":"import-export-mysql","status":"publish","type":"post","link":"https:\/\/blogs.giamkichsan.com\/index.php\/2025\/11\/16\/import-export-mysql\/","title":{"rendered":"Import &#8211; Export Mysql"},"content":{"rendered":"\n<p><strong>1. EXPORT 1 DATABASE<\/strong><\/p>\n\n\n\n<p>Gi\u1ea3 s\u1eed database c\u1ee7a b\u1ea1n t\u00ean: <strong>mydb<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udc49 Export database ra file SQL:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqldump -u root -p mydb &gt; mydb.sql\n<\/code><\/pre>\n\n\n\n<p>H\u1ec7 th\u1ed1ng s\u1ebd h\u1ecfi m\u1eadt kh\u1ea9u root \u2192 nh\u1eadp v\u00e0o.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udc49 N\u1ebfu database c\u00f3 nhi\u1ec1u d\u1eef li\u1ec7u, n\u00ean th\u00eam t\u1ed1i \u01b0u:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqldump -u root -p --single-transaction --quick --routines mydb &gt; mydb.sql\n<\/code><\/pre>\n\n\n\n<p>Gi\u1ea3i th\u00edch:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--single-transaction<\/code>: export nhanh, kh\u00f4ng kh\u00f3a b\u1ea3ng (cho InnoDB)<\/li>\n\n\n\n<li><code>--quick<\/code>: gi\u1ea3m d\u00f9ng RAM khi xu\u1ea5t file l\u1edbn<\/li>\n\n\n\n<li><code>--routines<\/code>: xu\u1ea5t c\u1ea3 stored procedures &amp; functions<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udfe6 <strong>2. IMPORT 1 DATABASE<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udc49 T\u1ea1o database tr\u01b0\u1edbc (n\u1ebfu ch\u01b0a c\u00f3)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p -e \"CREATE DATABASE mydb;\"\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udc49 Import file SQL v\u00e0o database:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p mydb &lt; mydb.sql\n<\/code><\/pre>\n\n\n\n<p>R\u1ea5t \u0111\u01a1n gi\u1ea3n: d\u00f9ng <code>&lt;<\/code> \u0111\u1ec3 n\u1ea1p file v\u00e0o MySQL.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udfe9 <strong>3. Export \/ Import 1 b\u1ea3ng (n\u1ebfu b\u1ea1n c\u1ea7n)<\/strong><\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">Export 1 b\u1ea3ng<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqldump -u root -p mydb mytable &gt; mytable.sql\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Import 1 b\u1ea3ng<\/h3>\n\n\n\n<p>mysql -u root -p mydb &lt; mytable.sql<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>!!!. \u0110\u1ed5i m\u1eadt kh\u1ea9u cho user root MySQL<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>C\u00e1ch 1: \u0110\u1ed5i m\u1eadt kh\u1ea9u sau khi \u0111\u0103ng nh\u1eadp MySQL<\/strong><\/h2>\n\n\n\n<p>\u0110\u0103ng nh\u1eadp:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p\n<\/code><\/pre>\n\n\n\n<p>Sau \u0111\u00f3 ch\u1ea1y:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MatKhauMoi123!';\nFLUSH PRIVILEGES;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>1. EXPORT 1 DATABASE Gi\u1ea3 s\u1eed database c\u1ee7a b\u1ea1n t\u00ean: mydb \ud83d\udc49 Export database ra file SQL: H\u1ec7 th\u1ed1ng s\u1ebd h\u1ecfi m\u1eadt kh\u1ea9u root \u2192 <a class=\"mh-excerpt-more\" href=\"https:\/\/blogs.giamkichsan.com\/index.php\/2025\/11\/16\/import-export-mysql\/\" title=\"Import &#8211; Export Mysql\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-mysql-he-quan-tri-co-so-du-lieu"],"_links":{"self":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":1,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}