Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On server my application is looking for uppercase table name instead of lowercase

I have this table on my local xampp , the table name is tags , this works perfectly fine on my local system, but when I upload this table to my server I get the following error:

enter image description here

The tables I have under the table peckinga_blog are the following:

enter image description here

As you can see tags is one of them , Also for the tags table I have the following migrations in my laravel application:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTagsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('Tags', function (Blueprint $table) {
            $table->increments('id');
            $table->mediumText('tag');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('Tags');
    }
}

Now why am I getting this this error in spite of my database clearly being available ? What can I do so that my server will look for the database tags instead of Tags ?

like image 570
Alexander Solonik Avatar asked Jan 31 '17 21:01

Alexander Solonik


1 Answers

Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix or Linux. Table names in MySQL are file system entries, so they are case insensitive if the underlying file system is.

Although after applying the migration, it should work But in case if it is not working and you want both statements i.e. lower case and upper case name in table to succeed, you need to put the following line

lower_case_table_names = 1

in your /etc/my.cnf or wherever you keep your MySQL configuration.

Doctrine generated capital/CamelCase table names and MySQL stored them as lowercase!

Or

  1. Before export the database from local you can do these steps:

  2. open your MySQL configuration file: [drive]\xampp\mysql\bin\my.ini

  3. look up for: # The MySQL server [mysqld]

  4. add this right below it: lower_case_table_names = 2

  5. save the file and restart MySQL service

Be sure to add the system variable to [mysqld] section of the configuration file.

For more information you can check the MySQL Reference Link.

like image 94
Deep Kakkar Avatar answered Sep 22 '22 18:09

Deep Kakkar