Laravel5.5问题:SQLSTATE[42000] Syntax error or access violation 1071 Specified key was too long; max k
来源:互联网 发布:魔镜淘宝助手插件下载 编辑:程序博客网 时间:2024/06/06 01:27
Laravel5.5 配置后台管理包Voyager问题:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
听说voyager不错,新建立一个文件尝试了一下,
D:\wamp64\www\laravel\myproject
λ> php artisan voyager:install –with-dummy
Setting up the hooksHooks are now ready to use! Go ahead and try to "php artisan hook:install test-hook"Publishing the Voyager assets, database, language, and config filesCopied Directory [\vendor\tcg\voyager\publishable\assets] To [\public\vendor\tcg\voyager\assets]Copied Directory [\vendor\tcg\voyager\publishable\database\migrations] To [\database\migrations]Copied Directory [\vendor\tcg\voyager\publishable\database\seeds] To [\database\seeds]Copied Directory [\vendor\tcg\voyager\publishable\demo_content] To [\storage\app\public]Copied Directory [\vendor\tcg\voyager\publishable\lang] To [\resources\lang]Publishing complete.Publishing complete.Migrating the database tables into your applicationMigration table created successfully. [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table users add unique users_email_unique(email)) [Doctrine\DBAL\Driver\PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
问题让人头大,根据laravel官方的文档,更改laravel5.5的文件( ../app/providers/appServiceProvider.php)内容 , 如下
<?phpnamespace App\Providers;use Illuminate\Support\ServiceProvider;use Illuminate\Support\Facades\Schema; //Import Schemaclass AppServiceProvider extends ServiceProvider{ /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); //Solved by increasing StringLength } /** * Register any application services. * * @return void */ public function register() { // }}
D:\wamp64\www\laravel\myproject
λ> php artisan voyager:install –with-dummy
Setting up the hooksHooks are now ready to use! Go ahead and try to "php artisan hook:install test-hook"Publishing the Voyager assets, database, language, and config filesCopied Directory [\vendor\tcg\voyager\publishable\assets] To [\public\vendor\tcg\voyager\assets]Copied Directory [\vendor\tcg\voyager\publishable\database\migrations] To [\database\migrations]Copied Directory [\vendor\tcg\voyager\publishable\database\seeds] To [\database\seeds]Copied Directory [\vendor\tcg\voyager\publishable\demo_content] To [\storage\app\public]Copied Directory [\vendor\tcg\voyager\publishable\lang] To [\resources\lang]Publishing complete.Publishing complete.Migrating the database tables into your applicationMigration table created successfully. [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `translations` add unique `translations_table_name_column_nam e_foreign_key_locale_unique`(`table_name`, `column_name`, `foreign_key`, `locale`)) [Doctrine\DBAL\Driver\PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
数据库显示,users和migration成功导入,其他还是失败了。最后到github找到这个解决方案
https://github.com/the-control-group/voyager/issues/901#issuecomment-291470960
1. Update the "config/database.php" for 'mysql''engine' => null,with'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',++++++++++++++++++++++++++++++++++++++++++++2. Update the "app/Providers/AppServiceProvider.php" with<?phpnamespace App\Providers;use Illuminate\Support\ServiceProvider;use Illuminate\Support\Facades\Schema;class AppServiceProvider extends ServiceProvider{ /** * Bootstrap any application services. * * @return void */ public function boot() { // Specified key was too long error, Laravel News post: Schema::defaultStringLength(191); } /** * Register any application services. * * @return void */ public function register() { // }}++++++++++++++++++++++++++++++++++++++++++++3. Execute Command:php artisan cache:clearphp artisan config:clearphp artisan voyager:install --with-dummyNow, everything works! :)
这里也有类似的问题:https://github.com/the-control-group/voyager/issues/1333
根据上述做了些更改,然后安装
D:\wamp64\www\laravel\myproject
λ> php artisan voyager:install –with-dummy
Setting up the hooksHooks are now ready to use! Go ahead and try to "php artisan hook:install test-hook"Publishing the Voyager assets, database, language, and config filesCopied Directory [\vendor\tcg\voyager\publishable\assets] To [\public\vendor\tcg\voyager\assets]Copied Directory [\vendor\tcg\voyager\publishable\database\migrations] To [\database\migrations]Copied Directory [\vendor\tcg\voyager\publishable\database\seeds] To [\database\seeds]Copied Directory [\vendor\tcg\voyager\publishable\demo_content] To [\storage\app\public]Copied Directory [\vendor\tcg\voyager\publishable\lang] To [\resources\lang]Publishing complete.Publishing complete.Migrating the database tables into your applicationMigration table created successfully.Migrating: 2014_10_12_000000_create_users_tableMigrated: 2014_10_12_000000_create_users_tableMigrating: 2014_10_12_100000_create_password_resets_tableMigrated: 2014_10_12_100000_create_password_resets_tableMigrating: 2016_01_01_000000_add_voyager_user_fieldsMigrated: 2016_01_01_000000_add_voyager_user_fieldsMigrating: 2016_01_01_000000_create_data_types_tableMigrated: 2016_01_01_000000_create_data_types_tableMigrating: 2016_01_01_000000_create_pages_tableMigrated: 2016_01_01_000000_create_pages_tableMigrating: 2016_01_01_000000_create_posts_tableMigrated: 2016_01_01_000000_create_posts_tableMigrating: 2016_02_15_204651_create_categories_tableMigrated: 2016_02_15_204651_create_categories_tableMigrating: 2016_05_19_173453_create_menu_tableMigrated: 2016_05_19_173453_create_menu_tableMigrating: 2016_10_21_190000_create_roles_tableMigrated: 2016_10_21_190000_create_roles_tableMigrating: 2016_10_21_190000_create_settings_tableMigrated: 2016_10_21_190000_create_settings_tableMigrating: 2016_11_30_135954_create_permission_tableMigrated: 2016_11_30_135954_create_permission_tableMigrating: 2016_11_30_141208_create_permission_role_tableMigrated: 2016_11_30_141208_create_permission_role_tableMigrating: 2016_12_26_201236_data_types__add__server_sideMigrated: 2016_12_26_201236_data_types__add__server_sideMigrating: 2017_01_13_000000_add_route_to_menu_items_tableMigrated: 2017_01_13_000000_add_route_to_menu_items_tableMigrating: 2017_01_14_005015_create_translations_tableMigrated: 2017_01_14_005015_create_translations_tableMigrating: 2017_01_15_000000_add_permission_group_id_to_permissions_tableMigrated: 2017_01_15_000000_add_permission_group_id_to_permissions_tableMigrating: 2017_01_15_000000_create_permission_groups_tableMigrated: 2017_01_15_000000_create_permission_groups_tableMigrating: 2017_01_15_000000_make_table_name_nullable_in_permissions_tableMigrated: 2017_01_15_000000_make_table_name_nullable_in_permissions_tableMigrating: 2017_03_06_000000_add_controller_to_data_types_tableMigrated: 2017_03_06_000000_add_controller_to_data_types_tableMigrating: 2017_04_11_000000_alter_post_nullable_fields_tableMigrated: 2017_04_11_000000_alter_post_nullable_fields_tableMigrating: 2017_04_21_000000_add_order_to_data_rows_tableMigrated: 2017_04_21_000000_add_order_to_data_rows_tableMigrating: 2017_07_05_210000_add_policyname_to_data_types_tableMigrated: 2017_07_05_210000_add_policyname_to_data_types_tableMigrating: 2017_08_05_000000_add_group_to_settings_tableMigrated: 2017_08_05_000000_add_group_to_settings_tableAttempting to set Voyager User model as parent to App\UserDumping the autoloaded files and reloading all new filesAdding Voyager routes to routes/web.phpSeeding data into the databaseAdding the storage symlink to your public folderThe [public/storage] directory has been linked.Successfully installed Voyager! Enjoy
成功!
分析:关键是这个:
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC'
上述这名话的意思是,采用MySQL存储引擎采用InnoDB(而不是MyISAM),动态文本格式。当然InnoDB不是没有缺点,这个大家可以自己进一步深入研究。
阅读全文
0 0
- Laravel5.5问题:SQLSTATE[42000] Syntax error or access violation 1071 Specified key was too long; max k
- Laravel migrate时报错: Syntax error or access violation: 1071 Specified key was too long
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL中ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes错误的处理
- 导数据遇到的ERROR 1071 (42000): Specified key was too long问题
- mysql [42000][1071] Specified key was too long; max key length is 767 bytes
- Specified key was too long; max key length is 767 bytes问题
- hive执行命令Specified key was too long; max key length is 767 bytes 问题
- 关于MySQL字符集问题:Specified key was too long; max key length is 767 bytes
- hive create table: Specified key was too long; max
- SQLSTATE[42000]: Syntax error or access violation: 1055 'kf_local.g.group_name' isn't in GROUP BY
- javaee权限管理shiro无效
- Java;C#/C++与Delphi/C++Builder之区别与联系
- WooCommerce接入支付宝支付功能(二)——WooCommerce中添加新的支付网关
- Java 下载文件,浏览器直接打开,并且PDF再次点击下载时,文件名称设置正确
- WebLogic安装教程
- Laravel5.5问题:SQLSTATE[42000] Syntax error or access violation 1071 Specified key was too long; max k
- AutoCAD.net-错误消息大全
- 1.Spring Boot 入门
- Centos7.4使用SoftEther搭建VPN
- idea学习
- VC实现透明图的闪屏对话框动画
- XML Namespace 命名空间
- Eclipse中的SVN提交前需要过滤的一些文件
- Pyhton之redis