没有不值得去解决的问题,也没有不值得去学习的技术!

Database Migration in Yii 2.0 Fails: Exception: Redis Error: ERR Client Sent AUTH, but No Password Is Set

During database migration in Yii 2.0, an error occurred: Exception: Redis error: ERR Client sent AUTH, but no password is set.

1. During database migration in Yii 2.0, an error occurred: Exception: Redis error: ERR Client sent AUTH, but no password is set. See Figure 1.

During database migration in Yii 2.0, an error occurred: Exception: Redis error: ERR Client sent AUTH, but no password is set.
Figure 1
Plaintext
*** applying m191113_084655_sync_redis_wx_auth_data_to_mysql
Exception: Redis error: ERR Client sent AUTH, but no password is set
Redis command was: AUTH Redis (E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2-redis\src\Connection.php:821)
#0 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2-redis\src\Connection.php(789): yii\redis\Connection->parseResponse(Array, '*2\r\n$4\r\nAUTH\r\n$...')
#1 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2-redis\src\Connection.php(772): yii\redis\Connection->sendCommandInternal('*2\r\n$4\r\nAUTH\r\n$...', Array)
#2 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2-redis\src\Connection.php(634): yii\redis\Connection->executeCommand('AUTH', Array)
#3 E:\wwwroot\channel-pub-api\console\migrations\m191113_084655_sync_redis_wx_auth_data_to_mysql.php(27): yii\redis\Connection->open()
#4 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\db\Migration.php(114): m191113_084655_sync_redis_wx_auth_data_to_mysql->safeUp()
#5 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(725): yii\db\Migration->up()
#6 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(200): yii\console\controllers\BaseMigrateController->migrateUp('m191113_084655_...')
#7 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#8 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#9 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\console\Controller.php(164): yii\base\Controller->runAction('', Array)
#11 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\base\Module.php(528): yii\console\Controller->runAction('', Array)
#12 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate', Array)
#13 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate', Array)
#14 E:\wwwroot\channel-pub-api\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#15 E:\wwwroot\channel-pub-api\yii(23): yii\base\Application->run()
#16 {main}
*** failed to apply m191113_084655_sync_redis_wx_auth_data_to_mysql (time: 0.011s)


2. Open a terminal and connect to redis-cli to test AUTH Redis. Error: (error) ERR Client sent AUTH, but no password is set

Plaintext
PS E:\wwwroot\channel-pub-api> redis-cli
127.0.0.1:6379> AUTH Redis
(error) ERR Client sent AUTH, but no password is set
127.0.0.1:6379>

3. Edit redis.windows.conf and redis.windows-service.conf to add requirepass Redis.

Plaintext
################################## SECURITY ###################################

# Require clients to issue AUTH  before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
# 
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass Redis

4. In Windows 10, stop and start Redis.

Plaintext
PS E:\wwwroot\channel-pub-api> redis-server --service-stop
[29528] 30 Mar 14:04:24.076 # Redis service successfully stopped.
PS E:\wwwroot\channel-pub-api> redis-server --service-start
[28132] 30 Mar 14:04:34.748 # Redis service successfully started.

5. Open a terminal and connect to redis-cli to test AUTH Redis. The response is OK. See Figure 2.

Open a terminal and connect to redis-cli to test AUTH Redis. The response is OK.
Figure 2
Plaintext
PS E:\wwwroot\channel-pub-api> redis-cli
127.0.0.1:6379> AUTH Redis
OK
127.0.0.1:6379>

6. The database migration in Yii 2.0 succeeds. See Figure 3.

The database migration in Yii 2.0 succeeds.
Figure 3
Plaintext
*** applying m191113_084655_sync_redis_wx_auth_data_to_mysql
*** applied m191113_084655_sync_redis_wx_auth_data_to_mysql (time: 0.266s)

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系