我正在尝试将我的 Laravel"(本地设置)项目与 cPanel Mysql 远程连接。但我遇到了问题。请帮我解决这个问题
已允许管理 SSH,并且我连接了 SSH 隧道。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=rashgsen_bdskills
DB_USERNAME=rashgsen_skills
DB_PASSWORD=B*****1desh@2020
当我尝试运行 php artisan migrate 时,它不起作用。错误显示。
SQLSTATE[HY000] [1045] Access denied for user 'rashgsen_skills'
@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = ra
shgsen_bdskills and table_name = migrations and table_type = 'BASE TABLE')
at F:\xamppnew\htdocs\laravel\skillsbd\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::("SQLSTATE[HY000] [1045] Access denied for user 'rashgsen_skills'@'localhost' (using
password: YES)")
F:\xamppnew\htdocs\laravel\skillsbd\vendor\laravel\framework\src\Illuminate\Database\Connectors\Co
nnector.php:70
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=rashgsen_bdskills", "rashgsen_skills", "Ba*****esh@2020", [])
F:\xamppnew\htdocs\laravel\skillsbd\vendor\laravel\framework\src\Illuminate\Database\Connectors\Co
nnector.php:70
最佳答案
你的环境应该是这样的
DB_CONNECTION=mysql
DB_HOST= // your cpanel domain ip address which u can see in statistics
DB_PORT=3306
DB_DATABASE= // cpanel mysql db name
DB_USERNAME= // cpanel mysql user
DB_PASSWORD= // cpanel mysql pssword
最后一步找到你的电脑 ip 地址并将其添加到 cpanel Romote Mysql
关于php - Laravel项目如何远程连接mysql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57844682/