1

I am changing database name here but it is not effective to change the database

Config::set('database.connections.mysql2.database', $dbName);
Config::set('database.default', 'mysql2');

Can any one help me on this?

1 Answer 1

2

you can change the database in laravel like this

           Config::set('database.connections.mysql2.database', $dbName);
           Config::set('database.default', 'mysql2');
           DB::reconnect('mysql2');

or you can use

DB::setDefaultConnection('mysql2');
Sign up to request clarification or add additional context in comments.

Comments

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.