I am trying to restore database from .sql file , i have created the database in phpmyadmin and also using the create if not exist command in the .sql file which i am restori
If initially typed the name of the database incorrectly. Then did a Php artisan migrate .You will then receive an error message .Later even if fixed the name of the databese you need to turn off the server and restart server
mysql -uroot -psecret mysql < mydatabase.sql
La Chi's answer works for me.
You can view his/her answer in the comment of zessx answer in this page. But I initially have a problem with it if you also do just tweak his/her answer like this: mysql -h localhost -u root -p -D mydatabase < mydatabase.sql
.
Also I would suggest that in the mydatabase.sql
portion you include the direct location of it in your computer like "C:\Users\username\desktop"
.
Thank you.
when u import database from workbench or other method ,should be give same name as your dump to avoid this kind of error
I solved because I have the same problem and I give you some clues:
1.- As @eggyal comments
mydatabase != mydatabasename
So, check your database name
2.- if in your file, you want create database, you can't set database that you not create yet:
mysql -uroot -pmypassword mydatabase<mydatabase.sql;
change it for:
mysql -uroot -pmypassword <mydatabase.sql;
You can also create a database named 'mydatabasename' and then try restoring it again.
Create a new database using MySQL CLI:
mysql -u[username] -p[password]
CREATE DATABASE mydatabasename;
Then try to restore your database:
mysql -u[username] -p[password] mydatabase<mydatabase.sql;