using different database at redis command prompt

RedisRedis Commands

Redis Problem Overview


dThe following works as expected. But how do I insert the data into forth database instead of default "0" from command prompt?

# echo -n "testing" | /home/shantanu/redis-2.4.2/src/redis-cli -x set my_pass
OK

# echo -n "testing" | /home/shantanu/redis-2.4.2/src/redis-cli -x select 4; set my_pass
(error) ERR wrong number of arguments for 'select' command

Redis Solutions


Solution 1 - Redis

Just use the -n argument to choose DB number. It available since Redis 2.4.2.

echo -n "testing" | redis-cli -n 4 -x set my_pass

or

redis-cli -n 4 set my_pass testing

Solution 2 - Redis

Launch the CLI by issuing command:

redis-cli

Then use the following command:

select <db number>

For example:

select 4

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshantanuoView Question on Stackoverflow
Solution 1 - Redismiaout17View Answer on Stackoverflow
Solution 2 - RedisavichalpView Answer on Stackoverflow