laravel7+安装laravel-admin操作流畅步骤及mysql5.5版本报错处理

2023-06-01 00:00:00 laravel 安装 laravel7

因为打算测试一下centos7+laravel+swoole全新安装了一些框架环境及一些常用扩展包出现的问题处理方式记录;这篇文章是接上一篇的,想了解的自行查阅

正常流水线作业安装

laravel7+我已经安装好 nginx配置好,mysql数据库建好设置远程连接,建了个控制器/view跑了一下正常

所以我直接在项目根目录开始安装

//换一下阿里的源
[[email protected] laraveltest]# composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

[[email protected] laraveltest]# composer require encore/laravel-admin
Using version ^1.8 for encore/laravel-admin
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals
  - Installing doctrine/event-manager (1.1.0): Downloading (100%)         
  - Installing doctrine/cache (1.10.2): Downloading (100%)         
  - Installing doctrine/dbal (2.10.2): Downloading (100%)         
  - Installing symfony/dom-crawler (v5.1.2): Downloading (100%)         
  - Installing encore/laravel-admin (v1.8.1): Downloading (100%)         
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
encore/laravel-admin suggests installing intervention/image (Required to handling and manipulation upload images (~2.3).)
encore/laravel-admin suggests installing spatie/eloquent-sortable (Required to built orderable gird.)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: encore/laravel-admin
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.

[[email protected] laraveltest]# php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"
Copied Directory [/vendor/encore/laravel-admin/config] To [/config]
Copied Directory [/vendor/encore/laravel-admin/resources/lang] To [/resources/lang]
Copied Directory [/vendor/encore/laravel-admin/database/migrations] To [/database/migrations]
Copied Directory [/vendor/encore/laravel-admin/resources/assets] To [/public/vendor/laravel-admin]
Publishing complete.

[root@www laraveltest]# php artisan admin:install

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [1045] Access denied for user 'root'@'172.18.1.230' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675| 

      +49 vendor frames 
  50  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

好开始报错了,上官网查了一下是我mysql5.5版本低的原因 

修复文件:App\Providers\AppServiceProvider.php;

添加信息:下面有//add fixed sql 字符串的地方

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema; //add fixed sql

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Schema::defaultStringLength(191); //add fixed sql
    }
}

修复完继续执行

[[email protected] laraveltest]# php artisan admin:install
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (0.06 seconds)
Migrating: 2016_01_04_173148_create_admin_tables
Migrated:  2016_01_04_173148_create_admin_tables (0.47 seconds)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (0.02 seconds)
Database seeding completed successfully.
Admin directory was created: /app/Admin
HomeController file was created: /app/Admin/Controllers/HomeController.php
AuthController file was created: /app/Admin/Controllers/AuthController.php
ExampleController file was created: /app/Admin/Controllers/ExampleController.php
Bootstrap file was created: /app/Admin/bootstrap.php
Routes file was created: /app/Admin/routes.php

好laravel-admin安装完成了 进去访问一下

1.png

官方文档:https://laravel-admin.org/docs/zh

相关文章