{"id":24824,"date":"2023-04-27T17:52:48","date_gmt":"2023-04-27T15:52:48","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=24824"},"modified":"2023-04-27T17:52:49","modified_gmt":"2023-04-27T15:52:49","slug":"redis-how-to-import-data-using-redis-cli-utility","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/","title":{"rendered":"Redis : How to import data using redis-cli utility"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction:<\/h2>\n\n\n\n<p>As you may know Redis is a <strong>nosql <\/strong>database.<\/p>\n\n\n\n<p>It uses key-value pairs to store data whereas SQL database works as a <strong>table-based relational database structure<\/strong>.<\/p>\n\n\n\n<p>We ever seen how to create entries in Redis using typical commands like HSET , SET ,ZADD and so on ( I will prepare a reminder of these commands with explanations  in an incoming blog )<\/p>\n\n\n\n<p>Today the topic is to get back a dataset and inject it in your Redis database.<\/p>\n\n\n\n<p>Redis has many ways to import data into a database: <\/p>\n\n\n\n<p>You can do it from an <strong>generated file<\/strong>,<strong>using a Redis script<\/strong> or <strong>from an existing Redis database<\/strong>.<\/p>\n\n\n\n<p>You can do it through many ways, for example if the user wants to works directly on the data without using classic Redis command ( working with a text editor for example ).<\/p>\n\n\n\n<p>So let&#8217;s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before adding data in the Redis database I will clean the database in order to see if the tests are working as expected ( If you only want to add directly the data to your database this action is not needed)<\/p>\n\n\n\n<p>To avoid that , I advice you to perform a backup of your existing database before anything.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Start Redis server<\/h4>\n\n\n\n<p>Use the <code>redis-server<\/code> command to start your server:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI1.png\" alt=\"\" class=\"wp-image-24828\" width=\"1028\" height=\"544\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI1.png 976w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI1-300x159.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI1-768x407.png 768w\" sizes=\"auto, (max-width: 1028px) 100vw, 1028px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Check your database status:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open a new Linux Window<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"304\" height=\"164\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI2.png\" alt=\"\" class=\"wp-image-24829\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI2.png 304w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI2-300x162.png 300w\" sizes=\"auto, (max-width: 304px) 100vw, 304px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use command to check if database is running:<\/li>\n<\/ul>\n\n\n\n<p><code>ps -eaf | grep redis<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI3.png\" alt=\"\" class=\"wp-image-24830\" width=\"1059\" height=\"161\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI3.png 981w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI3-300x46.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI3-768x117.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use Redis-cli utility <\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI4.png\" alt=\"\" class=\"wp-image-24832\" width=\"1059\" height=\"159\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI4.png 979w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI4-300x45.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI4-768x115.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<p>scan the keys number<\/p>\n\n\n\n<p>Use this command:<\/p>\n\n\n\n<p><code>info keyspace<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI5-1.png\" alt=\"\" class=\"wp-image-24834\" width=\"1058\" height=\"173\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI5-1.png 979w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI5-1-300x49.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI5-1-768x126.png 768w\" sizes=\"auto, (max-width: 1058px) 100vw, 1058px\" \/><\/figure>\n\n\n\n<p>Currently we can see that I have a database with a lot of keys , <strong>I will flush it as an example for our import data test.<\/strong><\/p>\n\n\n\n<p>I will use this command ( BE CAREFUL !ALWAYS GET A BACKUP BEFORE DOING SUCH A COMMAND ):<\/p>\n\n\n\n<p><code>flushdb<\/code><\/p>\n\n\n\n<p>Note that this command is different than <strong>flushall<\/strong> as it will only clean the current database used whereas <strong>flushall <\/strong>will clear ALL your databases so be careful !<\/p>\n\n\n\n<p>Here a link to <a href=\"https:\/\/redis.io\/commands\/flushdb\/\">Redis commands <\/a><\/p>\n\n\n\n<p>See all description of the <strong>FLUSHDB <\/strong>command <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI6-1024x734.png\" alt=\"\" class=\"wp-image-24836\" width=\"958\" height=\"687\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI6-1024x734.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI6-300x215.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI6-768x550.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI6.png 1174w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check if database is cleaned<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI7.png\" alt=\"\" class=\"wp-image-24838\" width=\"973\" height=\"160\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI7.png 979w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI7-300x49.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI7-768x126.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check on Redis Insight <\/li>\n<\/ul>\n\n\n\n<p>Database is empty <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI8-1024x635.png\" alt=\"\" class=\"wp-image-24839\" width=\"975\" height=\"604\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI8-1024x635.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI8-300x186.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI8-768x477.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI8.png 1286w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Import data using <code>redis-cli<\/code> script<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1st step create a text file<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Aim is to create a file containing Redis inputs to create add or delete users for example in your Linux machine type :<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>vi Best_Players_In_the_World.Redis<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs9-1.png\" alt=\"\" class=\"wp-image-24841\" width=\"942\" height=\"155\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs9-1.png 980w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs9-1-300x50.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs9-1-768x127.png 768w\" sizes=\"auto, (max-width: 942px) 100vw, 942px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then Inside add the Redis command for user creation<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><br>HSET 'user:001' first_name 'Nabil' last_name 'SAOUAL' dob '19-FEV-1979'<br>HSET 'user:002' first_name 'Ronaldo' last_name 'R9' dob '22-SEP-1976'<br>HSET 'user:003' first_name 'Diego Armando' last_name 'MARADONA' dob '30-OCT-1960'<br>HSET 'user:004' first_name 'Edson Arantes' last_name 'DO NASCIMENTO' dob '23-OCT-1940'<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI9.png\" alt=\"\" class=\"wp-image-24842\" width=\"942\" height=\"427\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI9.png 976w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI9-300x136.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLI9-768x349.png 768w\" sizes=\"auto, (max-width: 942px) 100vw, 942px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2nd step : Use the <strong>Redis-cli<\/strong> utility to run the script<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nredis-cli -h localhost -p 6379 &amp;lt; \/home\/nso\/DATA_TO_IMPORT\/Best_Players_In_the_World.redis\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs92-1024x160.png\" alt=\"\" class=\"wp-image-24845\" width=\"956\" height=\"149\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs92-1024x160.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs92-300x47.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs92-768x120.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs92.png 1027w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/figure>\n\n\n\n<p>If the command is successful you will have a message showing the integration of the data <\/p>\n\n\n\n<p><span style=\"text-decoration: underline\"><strong>Note:<\/strong><\/span><\/p>\n\n\n\n<p>You must specify the absolute path or launch the command from the script file location to get it work<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3rd step Check if change are commit<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check on Redis server <\/li>\n<\/ul>\n\n\n\n<p>Use the command:<\/p>\n\n\n\n<p><code>info keyspace<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"160\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs94-1024x160.png\" alt=\"\" class=\"wp-image-24847\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs94-1024x160.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs94-300x47.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs94-768x120.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs94.png 1027w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We see that 4 keys are now part of our empty database<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Refresh Redis insight and check if all is fine<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"446\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs93-1024x446.png\" alt=\"\" class=\"wp-image-24846\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs93-1024x446.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs93-300x131.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs93-768x334.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs93.png 1293w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We can already see that 4 keys are added , press refresh button to see it<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"657\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs95-1024x657.png\" alt=\"\" class=\"wp-image-24848\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs95-1024x657.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs95-300x192.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs95-768x493.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs95.png 1286w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>That&#8217;s it , we have imported data using <strong>redis-cl<\/strong>i utility \ud83d\ude42 <\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Bonus!<\/h2>\n\n\n\n<p>If you want to play around with some dataset you can import the dataset below ( the one used in my <a href=\"https:\/\/www.dbi-services.com\/blog\/redishands-on-with-redis-train-with-redisinsight-on-windows\/\">RedisInsight introduction blog<\/a> )<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/redis-developer\/redis-datasets\/blob\/master\/user-database\/import_users.redis\">https:\/\/github.com\/redis-developer\/redis-datasets\/blob\/master\/user-database\/import_users.redis<\/a><\/p>\n\n\n\n<p>But you can also use other datasets like movie or actors dataset.You can find it here:<br><a href=\"https:\/\/github.com\/redis-developer\/redis-datasets\/tree\/master\/movie-database\">https:\/\/github.com\/redis-developer\/redis-datasets\/tree\/master\/movie-database<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-21-1024x414.png\" alt=\"\" class=\"wp-image-24849\" width=\"858\" height=\"346\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-21-1024x414.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-21-300x121.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-21-768x311.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-21-1536x621.png 1536w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-21.png 1919w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/figure>\n\n\n\n<p>You just have to download them and to inject them to your Database using the <strong>Redis-cli <\/strong>script <\/p>\n\n\n\n<p>So, you can see a sample of movie dataset ( you will remark that <strong>HSET <\/strong>command is used as for my previous file creation,of course you can use other Redis commands to edit your datasets )<\/p>\n\n\n\n<p>Thanks to <a href=\"https:\/\/github.com\/tgrall\">tgrall <\/a>for his work \ud83d\ude42 <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-22-1024x514.png\" alt=\"\" class=\"wp-image-24850\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-22-1024x514.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-22-300x151.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-22-768x386.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-22.png 1129w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Lets&#8217; add it to our DB !<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Right click on the redis file and chose Save Link As option<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"520\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-23-1024x520.png\" alt=\"\" class=\"wp-image-24852\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-23-1024x520.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-23-300x152.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-23-768x390.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/image-23.png 1094w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Add it to your folder on your Linux machine<\/p>\n\n\n\n<p>if you use <strong>WSL <\/strong>you can access form your windows machine form here<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\\wsl$\\YourDistro<\/code><\/pre>\n\n\n\n<p>Example for me:<\/p>\n\n\n\n<p>\\wsl$\\openSUSE-Leap-15.4\\home\\nso\\DATA_TO_IMPORT<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs98-1024x386.png\" alt=\"\" class=\"wp-image-24856\" width=\"992\" height=\"373\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs98-1024x386.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs98-300x113.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs98-768x290.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs98-1536x579.png 1536w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs98.png 1663w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Repeat the import action and see if all is working \ud83d\ude42<\/li>\n<\/ul>\n\n\n\n<p>Seems to get some issues during the import but you can do some queries without any trouble ( I have directly  made a copy paste of data contained in the <strong>import_movies.redis<\/strong> file because some elements were interfering during the import.)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"681\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99-1024x681.png\" alt=\"\" class=\"wp-image-24857\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99-1024x681.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99-300x200.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99-768x511.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png 1281w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You have now imported some dataset, like this,you will be able to practice and perform some queries <\/p>\n\n\n\n<p>See that it was added in a specific folder,  different from my first user creation  as we used different fields for that \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion:<\/h2>\n\n\n\n<p>Now you know how to import your own dataset by creating a script and where to find some examples to use, next step we will see how to backup and restore all this work !!<\/p>\n\n\n\n<p>Don&#8217;t forget to visit <a href=\"https:\/\/www.dbi-services.com\/blog\/microsoftbackup-and-restore-your-distribution-on-wsl\/\">my other blogs<\/a> and also the <a href=\"https:\/\/www.dbi-services.com\/blog\/\">dbi bloggers<\/a> to get more and more interesting tips!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: As you may know Redis is a nosql database. It uses key-value pairs to store data whereas SQL database works as a table-based relational database structure. We ever seen how to create entries in Redis using typical commands like HSET , SET ,ZADD and so on ( I will prepare a reminder of these [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":24857,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1739],"tags":[947],"type_dbi":[],"class_list":["post-24824","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nosql","tag-nosql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Redis : How to import data using redis-cli utility - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Redis : How to import data using redis-cli utility\" \/>\n<meta property=\"og:description\" content=\"Introduction: As you may know Redis is a nosql database. It uses key-value pairs to store data whereas SQL database works as a table-based relational database structure. We ever seen how to create entries in Redis using typical commands like HSET , SET ,ZADD and so on ( I will prepare a reminder of these [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-27T15:52:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-27T15:52:49+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1281\" \/>\n\t<meta property=\"og:image:height\" content=\"852\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Middleware Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Middleware Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/\"},\"author\":{\"name\":\"Middleware Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\"},\"headline\":\"Redis : How to import data using redis-cli utility\",\"datePublished\":\"2023-04-27T15:52:48+00:00\",\"dateModified\":\"2023-04-27T15:52:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/\"},\"wordCount\":795,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png\",\"keywords\":[\"NoSQL\"],\"articleSection\":[\"NoSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/\",\"name\":\"Redis : How to import data using redis-cli utility - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png\",\"datePublished\":\"2023-04-27T15:52:48+00:00\",\"dateModified\":\"2023-04-27T15:52:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png\",\"contentUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png\",\"width\":1281,\"height\":852},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Redis : How to import data using redis-cli utility\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\",\"name\":\"Middleware Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"caption\":\"Middleware Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/middleware-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Redis : How to import data using redis-cli utility - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/","og_locale":"en_US","og_type":"article","og_title":"Redis : How to import data using redis-cli utility","og_description":"Introduction: As you may know Redis is a nosql database. It uses key-value pairs to store data whereas SQL database works as a table-based relational database structure. We ever seen how to create entries in Redis using typical commands like HSET , SET ,ZADD and so on ( I will prepare a reminder of these [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/","og_site_name":"dbi Blog","article_published_time":"2023-04-27T15:52:48+00:00","article_modified_time":"2023-04-27T15:52:49+00:00","og_image":[{"width":1281,"height":852,"url":"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png","type":"image\/png"}],"author":"Middleware Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Middleware Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/"},"author":{"name":"Middleware Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"headline":"Redis : How to import data using redis-cli utility","datePublished":"2023-04-27T15:52:48+00:00","dateModified":"2023-04-27T15:52:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/"},"wordCount":795,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png","keywords":["NoSQL"],"articleSection":["NoSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/","url":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/","name":"Redis : How to import data using redis-cli utility - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png","datePublished":"2023-04-27T15:52:48+00:00","dateModified":"2023-04-27T15:52:49+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/04\/REDCLIs99.png","width":1281,"height":852},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/redis-how-to-import-data-using-redis-cli-utility\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Redis : How to import data using redis-cli utility"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1","name":"Middleware Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","caption":"Middleware Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/middleware-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/24824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=24824"}],"version-history":[{"count":21,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/24824\/revisions"}],"predecessor-version":[{"id":24868,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/24824\/revisions\/24868"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/24857"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=24824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=24824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=24824"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=24824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}