php mysql怎么运行,php – 如何使用laravel运行MySql 8?

我很难让MySQL 8工作.这是我每次尝试php工匠迁移时出现的错误.到目前为止,我只重新安装了一次MySQL,因为我不想再对正在发生的事情造成伤害.我已经从其他可能的答案中编辑了database.php,但这似乎也不起作用.我看到了一个可能的答案,这是因为MySQL 8的sha256加密了root密码,这就是为什么我要回到MySQL 5.7,我已经查找了与laravel工作正常.虽然,我想保持最新的软件包并保留MySQL 8,只要我可以使用laravel.

PHP 7.2

如何让MySQL 8与Laravel协同工作?

'mysql' => [

'driver' => 'mysql',

'host' => env('DB_HOST', '127.0.0.1'),

'port' => env('DB_PORT', '3306'),

'database' => env('DB_DATABASE', 'forge'),

'username' => env('DB_USERNAME', 'forge'),

'password' => env('DB_PASSWORD', ''),

'unix_socket' => env('DB_SOCKET', ''),

'charset' => 'utf8',

'collation' => 'utf8_unicode_ci',

'prefix' => '',

'prefix_indexes' => true,

'strict' => true,

'engine' => null,

'version' => 8,

'modes' => [

'ONLY_FULL_GROUP_BY',

'STRICT_TRANS_TABLES',

'NO_ZERO_IN_DATE',

'NO_ZERO_DATE',

'ERROR_FOR_DIVISION_BY_ZERO',

'NO_ENGINE_SUBSTITUTION',

],

],

Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = laravel_tut and table_name = migrations)

at /Users/home/Projects/laravel_tut/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664

660| // If an exception occurs when attempting to run a query, we'll format the error

661| // message to include the bindings with SQL, which will make this exception a

662| // lot more helpful to the developer instead of just the database's errors.

663| catch (Exception $e) {

> 664| throw new QueryException(

665| $query, $this->prepareBindings($bindings), $e

666| );

667| }

668|

Exception trace:

1 PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]")

/Users/home/Projects/laravel_tut/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel_tut", "root", "fdgkadgaf9g7ayaig9fgy9ad8fgu9adfg9adg", [])

/Users/home/Projects/laravel_tut/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

更新我要修复的另一个修正:

通过全新安装MySQL,我选择了NO来加密设置中的密码(使用传统加密,而不是SHA加密),它开始与Laravel一起使用没有任何问题 – 只需使用长而强的密码.

安装步骤的参考:

https://www.percona.com/blog/wp-content/uploads/2018/05/Installing-MySQL-8.0-on-Ubuntu-2.png

解决方法:

由于PHP不了解caching_sha2_password,请将用户设置回mysql_native_password:

ALTER USER 'forge'@'localhost'

IDENTIFIED WITH mysql_native_password BY 'new_password'

标签:php,laravel,mysql,ubuntu,server

来源: https://codeday.me/bug/20191001/1840061.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值