It's actually my fault that I did not think about it earlier that, my remote server MySQL version (on shared hosting) is 5.5.6
, but my local MySQL version is 5.7.19
.
I developed a Laravel (v6.6.0
) Web Application, where I ran the migration on the very first run, but as it's completely a personal project, I continued modifying the database by hand where and how necessary, (but off-the-record, I kept changing the migration files as well though I never ran them after the first instance).
I migrated all the data from some other tables and my application was ready to deploy. But when I was exporting the local database tables, and importing them to the remote database, it's giving me a well-known error:
Specified key was too long; max key length is 767 bytes
I actually ignored it because all the tables were imported nicely. But recently I found its caveats - all the AUTO_INCREAMENT
and PRIMARY_KEY
are not present on my remote database.
I searched what I could, but all the solutions are suggesting to delete the database and create it again with UTF-8 actually could not be my case. And a solution like the following PHP-way is also not my case as I'm using PHPMyAdmin to Import my table while I'm getting the error:
// File: app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
I also tried running the following command on my target database:
SET @global.innodb_large_prefix = 1;
But no luck. I also tried replacing all the occurrences of my .sql
local file:
- from
utf8mb4
toutf8
, and - from
utf8mb4_unicode_ci
toutf8_general_ci
but found no luck again.
From where the error specifically is coming from, actually the longer foreign keys, like xy_section_books_price_unit_id_foreign
, and at this stage when everything is done, I don't know how can I refactor all the foreign keys to 5.5
compatible.
Can anybody please shed some light on my issue?
How can I deploy my local database (v5.7
) without losing my PRIMARY_KEY
s, FOREIGN KEYS and INDEX
es to a v5.5
MySQL database keeping the data intact?