<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Divine Ayerume</title>
    <description>The latest articles on DEV Community by Divine Ayerume (@divineayerume).</description>
    <link>https://dev.to/divineayerume</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F867624%2Fde653d85-ff9d-47b8-8bad-75e53d99c371.png</url>
      <title>DEV Community: Divine Ayerume</title>
      <link>https://dev.to/divineayerume</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/divineayerume"/>
    <language>en</language>
    <item>
      <title>How to restore a postgreSQL database using command line</title>
      <dc:creator>Divine Ayerume</dc:creator>
      <pubDate>Wed, 25 May 2022 12:52:21 +0000</pubDate>
      <link>https://dev.to/divineayerume/how-to-restore-a-postgresql-database-using-command-line-54al</link>
      <guid>https://dev.to/divineayerume/how-to-restore-a-postgresql-database-using-command-line-54al</guid>
      <description>&lt;p&gt;In this article, I will be talking about One of the quickest ways to restore a database backup file on postgresql. When working with a new database file, it is more convenient to use the command line to restore the database, especially if the file is large so as to reduce query execution time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Locating the database file&lt;/strong&gt;&lt;br&gt;
The first step is determine the location of the ".sql" file on your computer and change the directory in command line to the folder containing the database. In the example below we'll be using the "store.sql" database which is located in downloads. To change the directory you type "cd" followed by the file path then press Enter to switch to the new directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Rovx9pqy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8uflvgs5umhrn2ydusw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rovx9pqy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8uflvgs5umhrn2ydusw.PNG" alt="Changing command line directory to the location of the database" width="880" height="496"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;2. Running the postgresql application in command line&lt;/strong&gt;&lt;br&gt;
After switching to the directory containing the database file, the next step is to run the postgersql executable file "psql.exe" in command line so that the database will be inserted through postgresql. to do this you have to copy the file path that contains the "psql.exe" file and the paste it in the command line wrapped up in quotes, this is to let the command line know that it should be run together.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3_0M_fgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmvm4kqi1yknsgcjoc5u.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3_0M_fgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmvm4kqi1yknsgcjoc5u.PNG" alt="Running the psql executable file in command line" width="880" height="510"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;3. Creating the database in PostgreSQL&lt;/strong&gt;&lt;br&gt;
The next step is to create a database, this is the database that will house the backup file and this can be done using pgadmin. For this example we will create a database and name it "Store".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Na7hKCpY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5du1sso6sn0hu89iye7b.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Na7hKCpY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5du1sso6sn0hu89iye7b.PNG" alt="creating a database on pdadmin" width="638" height="625"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;4. Upload the backup database file into the created database&lt;/strong&gt;&lt;br&gt;
The last step is to upload the ".sql" file into the database that was created with pgadmin. to do this, following the line of code in step 2, you have to indicate the user "-U username" and the database "-d database_name". In this example the user is "postgres" which is the same as the "owner" from the picture in step 3, and the database_name is "Store", created in the previous step. once the user and the database have been indicated, you type "&amp;lt;" followed by the file name "store.sql" then press Enter to upload the database. you will the be prompted to input your user password and after the password has been correctly inputted, the backup file will be uploaded into the database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8yz0rv8Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb209629jqk5t0bc0aro.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8yz0rv8Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb209629jqk5t0bc0aro.PNG" alt="Uploading the backup file to the created database" width="880" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
