In the console command of Yii 2.0, when connecting to Redis, an error is reported: yii\db\exception: redis error: err invalid db index redis command was: select Analysis of 29 in /vendor/yiisoft/yii2-redis/src/connection.php:736
1. In the console command of Yii 2.0, an error is reported: yii\db\exception: redis error: err Invalid DB index
Redis command was: Select 29 in /vendor/yiisoft/yii2-redis/src/connection.php:736, view /console/runtime/logs/app.log
2019-08-09 09:44:13 [-][-][-][error][yii\db\Exception] yii\db\Exception: Redis error: ERR invalid DB index
Redis command was: SELECT 29 in /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php:736
Stack trace:
#0 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(713): yii\redis\Connection->parseResponse('SELECT 29')
#1 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(697): yii\redis\Connection->sendCommandInternal('*2\r\n$6\r\nSELECT\r...', Array)
#2 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(559): yii\redis\Connection->executeCommand('SELECT', Array)
#3 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(665): yii\redis\Connection->open()
#4 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(630): yii\redis\Connection->executeCommand('SET', Array)
#5 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php(135): yii\redis\Connection->__call('set', Array)
#6 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php(59): yii\queue\redis\Queue->reserve(3)
#7 [internal function]: yii\queue\redis\Queue->yii\queue\redis\{closure}(Object(Closure))
#8 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func(Object(Closure), Object(Closure))
#9 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php(68): yii\queue\cli\Queue->runWorker(Object(Closure))
#10 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-queue/src/drivers/redis/Command.php(76): yii\queue\redis\Queue->run(true, 3)
#11 [internal function]: yii\queue\redis\Command->actionListen(3)
#12 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#14 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('listen', Array)
#15 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('listen', Array)
#16 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('upload-asset-qu...', Array)
#17 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('upload-asset-qu...', Array)
#18 /sobey/www/channel-pub-api/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#19 /sobey/www/channel-pub-api/yii(23): yii\base\Application->run()
#20 {main}
2. The analysis found that when executing the command: Select 29, switch to the corresponding database: 29 errors, and a Redis instance has 16 databases by default, from 0 – 15, it will report err if it exceeds this range. Invalid DB index, as shown in Figure 1
#0 /sobey/www/channel-pub-api/vendor/yiisoft/yii2-redis/src/Connection.php(713): yii\redis\Connection->parseResponse('SELECT 29')
3. Edit redis.windows.conf and redis.windows-service.conf files, find: databases 16, modify to: databases 32
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT where
# dbid is a number between 0 and 'databases'-1
databases 32
4. In Windows 10, stop and start Redis
PS C:\> redis-server --service-stop
[87292] 09 Aug 10:44:18.772 # Redis service successfully stopped.
PS C:\> redis-server --service-start
[77236] 09 Aug 10:44:31.673 # Redis service successfully started.
5. Open RedisDesktopManager, the number changes to 20, but you can already execute the command of select 0 – 31, as shown in Figure 2
6. Delete the connection, new connection settings – advanced settings – database discovery limit, its value defaults to 20 , and edits to 32, as shown in Figure 3
7. Open RedisDesktopManager, the number changes to 32, which is in line with expectations, as shown in Figure 4



