0

I am newbie to Laravel 5 and 6. I have very specific question, solution was developed using laravel and MSSQL server as DB server. Now I want to change Database from MSSQL to MySQL, is there any automated way to achieve this ? Or how cumbersome is this process and what will be the step to achieve this?

Thanks & regards

1 Answer 1

2

If with solution, you mean to migrate the logic and don't care about data.

  • Simply create a new database in MySQL.
  • Config .env file to use said db, for example:
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=my-db-name-here
    DB_USERNAME=root
    DB_PASSWORD=
    
  • Clear all cache, like:
    php artisan config:clear --no-ansi
    php artisan cache:clear --no-ansi
    composer dump-autoload
    php artisan view:clear --no-ansi
    php artisan route:clear --no-ansi
    
  • Test if the routes work, like:
    php artisan route:list --no-ansi
    
  • At last, recreate DB structure, like:
    php artisan migrate --no-ansi
    

If your project is new, there are no seed, else another useful command would be:

php artisan db:seed --no-ansi

But if Data are required:

The steps are basically the same as above;

But either you need to follow instructions at: https://www.thegeekstuff.com/2014/03/mssql-to-mysql/

Which shows how to directly copy data from source DB to destination.

Or you will need to:

  • Export your MS SQL Server as SQL-file (or zip).
  • Find/pick a tool, which converts SQL-files from "MS SQL Server" syntax/format to "MySQL" format.
  • Import resulting SQL-file in MySQL.
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Top Master for reply. I do care about data. I try this without data as well.
@user940959 See update! - normally my Laravel Apps do not depend on data (and migrate is enough), but I understand that it's required in some cases ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.