简体   繁体   English

Mysql 端口 3308 未与 127.0.0.1:8000 连接 laravel 6* 在 wamp 3.2

[英]Mysql Port 3308 is not getting connected with 127.0.0.1:8000 laravel 6* in wamp 3.2

This is my.env file with required changes这是带有所需更改的 my.env 文件

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:NReElKvDMYvjmIci0h3E9fsvWssYhz0Ld/jeuqWNlCc=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3308
DB_DATABASE=studmgmt
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

This is my database.php file这是我的数据库。php 文件

<?php

use Illuminate\Support\Str;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'url' => env('DATABASE_URL'),
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ],

        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3308'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer body of commands than a typical key-value system
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'client' => env('REDIS_CLIENT', 'phpredis'),

        'options' => [
            'cluster' => env('REDIS_CLUSTER', 'redis'),
            'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
        ],

        'default' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_DB', '0'),
        ],

        'cache' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_CACHE_DB', '1'),
        ],

    ],

];

I am using Laravel 6.* and Mysql 8.0.18.我正在使用 Laravel 6.* 和 Mysql 8.0.18。 I am using Mysql hence i changed it's port in.env and database file from 3306 to 3308. And i am routing the laravel as 127.0.0.1:8000.我正在使用 Mysql 因此我将它的端口 in.env 和数据库文件从 3306 更改为 3308。我将 laravel 路由为 127.0.0.1:8000。 It's not updating with created database and showing error that default database Laravel is not found as below -它没有使用创建的数据库进行更新并显示错误,即找不到默认数据库 Laravel,如下所示 -

Illuminate\Database\QueryException SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from students ) Illuminate\Database\QueryException SQLSTATE[HY000] [1049] 未知数据库 'laravel' (SQL: select * 来自students )

Please help me out where i am making mistake.请帮我找出我犯错的地方。 Thanks in advance for help.提前感谢您的帮助。

Just so everyon can see the answer without looking through the comments..让大家不用看评论就能看到答案。。

After changing DB settings in laravel, you need to remember executing the following command:更改 laravel 中的 DB 设置后,您需要记住执行以下命令:

php artisan cache:clear

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Laravel Framework 5.1在端口3308上连接MySQL数据库? - How to connect to MySQL database on port 3308 using laravel framework 5.1? Laravel 在“localhost:http://127.0.0.1:8000/”中显示错误 - Laravel shows error in “localhost:http://127.0.0.1:8000/” Laravel 5.6 http://127.0.0.1:8000/ 重定向到 https://127.0.0.1:8000/login (https) - Laravel 5.6 http://127.0.0.1:8000/ redirecting to https://127.0.0.1:8000/login (https) Vanilo Laravel 7 错误 403 - 在 http://127.0.0.1:8000/admin/customer 中禁止 - Vanilo Laravel 7 error 403 - Forbidden in http://127.0.0.1:8000/admin/customer 找不到在端口 8000 中运行的 laravel - Cant find laravel running in port 8000 GET http://127.0.0.1:8000/ 500(内部服务器错误) Laravel - GET http://127.0.0.1:8000/ 500 (Internal Server Error) Laravel wamp / composer / laravel5:localhost:8000只是无故停止工作 - wamp / composer/ laravel5 : localhost:8000 just stopped working for no reason 一起使用 symfony 和 laravel:本地服务器无法侦听 127.0.0.1:8000 - using symfony and laravel together : local server Failed to listen on 127.0.0.1:8000 文件链接在本地主机 http://127.0.0.1:8000 上的 laravel 中不可用 - File Link is not wok in laravel on localhost http://127.0.0.1:8000 http://127.0.0.1:8000 显示 Laravel 官方网站文档页面不显示基本第一次 Laravel 网站 - http://127.0.0.1:8000 Showing Laravel Official Site Documentation Page NOT Showing basic First Time Laravel Site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM