{"id":130292,"date":"2022-12-05T12:45:42","date_gmt":"2022-12-05T12:45:42","guid":{"rendered":"https:\/\/phppot.com\/?p=20093"},"modified":"2022-12-05T12:45:42","modified_gmt":"2022-12-05T12:45:42","slug":"phpmyadmin-how-to-import-a-database","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/12\/05\/phpmyadmin-how-to-import-a-database\/","title":{"rendered":"phpMyAdmin \u2013 How to Import a Database?"},"content":{"rendered":"<div class=\"modified-on\" readability=\"7.1304347826087\"> by <a href=\"https:\/\/phppot.com\/about\/\">Vincy<\/a>. Last modified on December 5th, 2022.<\/div>\n<p>In this tutorial, we are going to learn how to import MySQL database using phpMyAdmin. There are two ways to do the import via this PHP application.<\/p>\n<ol>\n<li>Go to the \u201cImport\u201d tab in the phpMyAdmin and upload a file(SQL, CSV \u2026) source that contains the database dumb.<\/li>\n<li>Choose a database and drag and drop the import file to the phpMyAdmin interface.<\/li>\n<\/ol>\n<h2><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Sections:\\nHow to import?\\nImport CSV\\nImport large SQL file&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:513,&quot;3&quot;:{&quot;1&quot;:0},&quot;12&quot;:0}\">How to import?<\/span><\/h2>\n<p>Open the phpMyAdmin application and create a connection by logging in with the host, user and password. Then, follow the below steps to <a href=\"https:\/\/phppot.com\/php\/how-to-import-sql-into-a-database-using-php\/\">import a database<\/a>.<\/p>\n<p>1) Choose the \u201cDatabase\u201d link and create a new or select an existing database. In a previous tutorial, we have seen the possible options of <a href=\"https:\/\/phppot.com\/mysql\/phpmyadmin-create-database\/\">creating a database using phpMyAdmin<\/a>.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-20104\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/create-database-550x221.jpg\" alt=\"create database\" width=\"550\" height=\"221\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/create-database-550x221.jpg 550w, https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/create-database-300x121.jpg 300w, https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/create-database.jpg 600w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<p>2) Choose the file in .sql (or other phpMyAdmin-supported) format.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-20105\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/choose-import-file-550x325.jpg\" alt=\"choose import file\" width=\"550\" height=\"325\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/choose-import-file-550x325.jpg 550w, https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/choose-import-file-300x178.jpg 300w, https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/choose-import-file.jpg 600w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<p>3) [optional] Choose char-set, SQL compatibility modes and other options like,<\/p>\n<ul>\n<li>Foreign key checks.<\/li>\n<li>Partial import.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-20106\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/phpmyadmin-import-options-550x557.jpg\" alt=\"phpmyadmin import options\" width=\"550\" height=\"557\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/phpmyadmin-import-options-550x557.jpg 550w, https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/phpmyadmin-import-options-296x300.jpg 296w, https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/phpmyadmin-import-options-768x778.jpg 768w, https:\/\/phppot.com\/wp-content\/uploads\/2022\/12\/phpmyadmin-import-options.jpg 1000w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<p>Click \u201cGo\u201d to complete the import.<\/p>\n<h2><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Sections:\\nHow to import?\\nImport CSV\\nImport large SQL file&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:513,&quot;3&quot;:{&quot;1&quot;:0},&quot;12&quot;:0}\">Import CSV<\/span><\/h2>\n<p>If you have the SQL dumb in a form of a CSV file, the phpMyAdmin allows that format to import.<\/p>\n<p>Change the format to the CSV from the default format. The SQL is the default format that the phpMyAdmin populates under the \u201cFormat\u201d section.<\/p>\n<p>It is suitable to import a database containing a single table. If the import file contains multiple tables then the import will merge all into one.<\/p>\n<p>It creates auto-generated columns like COL1, COL2\u2026 and stores the other comma-separated values as data.<\/p>\n<p>Note the following <a href=\"https:\/\/phppot.com\/php\/import-csv-file-into-mysql-using-php\/\">CSV format to import a database table<\/a>.<\/p>\n<pre class=\"prettyprint\"><code class=\"language-html\">\"id\",\"question\",\"answer\" \"1\",\" What are the widely used array functions in PHP?\",\"Answer1\" \"2\",\"How to redirect using PHP?\",\"Answer2\" \"3\",\" Differentiate PHP size() and count():\",\"Answer3\" \"4\",\"What is PHP?\",\"Answer4\" \"5\",\"What is php.ini?\",\"Answer5\"\n<\/code><\/pre>\n<h2><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Sections:\\nHow to import?\\nImport CSV\\nImport large SQL file&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:513,&quot;3&quot;:{&quot;1&quot;:0},&quot;12&quot;:0}\">Import large SQL file<\/span><\/h2>\n<p>Note the maximum file size allowed to upload via the phpMyAdmin application. It is near the \u201cChoose File\u201d option on the Import page.<\/p>\n<p>If the import file is too large, then it interrupts to skip the number of queries during the import.<\/p>\n<p>It is better to process import via Terminal if the import file exceeds the allowed limit. It will prevent the data inconsistency that may occur because of the partial import.<\/p>\n<p>Note the below Terminal command to process importing larger SQL files.<\/p>\n<pre class=\"prettyprint\"><code>#path-to-mysql#mysql -u root -p #database_name# &lt; #path-of-the-sql-file#\n<\/code><\/pre>\n<p>Replace the following variable in the above command<\/p>\n<ul>\n<li>#path-to-mysql# \u2013 Path where the MySQL is. Example: \/Applications\/XAMPP\/bin\/mysql<\/li>\n<li>#database_name# \u2013 The target database where the import is going to happen.<\/li>\n<li>#path-of-the-sql-file# \u2013 The path of the source SQL to import. Example: \/Users\/vincy\/Desktop\/db_phppot_example.sql<\/li>\n<\/ul>\n<p>The command line execution is also used to connect the remote server. It is in case of facing restrictions to access a remote MySQL server via phpMyAdmin.<\/p>\n<h2>Features of the phpMyAdmin Import<\/h2>\n<p>The phpMyAdmin \u201cImport\u201d functionality provides several features.<\/p>\n<ul>\n<li>It allows the import of files in the following formats. The default format is SQL.\n<ul>\n<li>CSV<\/li>\n<li>ESRI shape file<\/li>\n<li>MediaWiki table<\/li>\n<li>OpenDocument spreadsheet<\/li>\n<li>SQL<\/li>\n<li>XML<\/li>\n<\/ul>\n<\/li>\n<li>It allows choosing character sets and SQL compatibility modes.<\/li>\n<li>It allows partial imports by allowing interruptions during the import of larger files.<\/li>\n<\/ul>\n<h2>Things to remember<\/h2>\n<p>When you import a database or table certain things to remember.<\/p>\n<h3>Database resource \u201cAlready exists\u201d error<\/h3>\n<p>This error will occur if the importing file contains statements of existing resources.<\/p>\n<p>Example:<br \/>If the importing file has the query to create an existing table, then phpMyAdmin will show this error.<\/p>\n<p>So, it is important to clean up the existing state before importing a database to avoid this problem.<\/p>\n<h3>Access denied error<\/h3>\n<p>If the users have no permission to import or create databases\/tables, then it will return this error.<\/p>\n<p>If the user can import and can\u2019t create tables, the file must contain allowed queries only.<\/p>\n<p><strong>Note:<\/strong><span data-offset-key=\"1t8uh-0-1\"> If you are importing via remote access, give the right credentials to connect. Make sure about the user access privileges to import or related operations.<\/span><\/p>\n<p> <!-- #comments --> <\/p>\n<div class=\"related-articles\">\n<h2>Popular Articles<\/h2>\n<\/p><\/div>\n<p> <a href=\"https:\/\/phppot.com\/mysql\/phpmyadmin-import-database\/#top\" class=\"top\">\u2191 Back to Top<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>by Vincy. Last modified on December 5th, 2022. In this tutorial, we are going to learn how to import MySQL database using phpMyAdmin. There are two ways to do the import via this PHP application. Go to the \u201cImport\u201d tab in the phpMyAdmin and upload a file(SQL, CSV \u2026) source that contains the database dumb. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":130293,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[],"class_list":["post-130292","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-updates"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/130292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=130292"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/130292\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media\/130293"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=130292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=130292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=130292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}