LoginSignup
0

More than 3 years have passed since last update.

redis-cliの接続時によく使うコマンド使い方メモ

Last updated at Posted at 2019-07-09

redis-cliの接続時によく使うコマンド使い方メモ

redis起動

redisが起動していない時の起動方法
sudo redis-server /etc/redis.conf

redisへの接続方法

redis-cli -c -p 6379 -h {hostname}

ローカル環境の場合は以下

redis-cli -c -p 6379 -h 127.0.0.1

-cはクラスタモードで接続する場合

データベースの指定

Redisはデフォルトで16個のデータベースがあり、
それぞれ0~15のindexが割り当てられている。

SELECTで使用するDBを指定できる

mysqlでいうところのuse {schema名}のようなDB指定のイメージ

SELECT {index}

データベース数の確認

config get databasesで現在のデータベース数を確認できる

127.0.0.1:6379> config get databases
1) "databases"
2) "16"

次回はDBの中身確認コマンドメモにします。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0