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 dump file contains:
CREATE DATABASE mydatabasename; USE mydatabasename;
You may just use in CLI:
mysql -uroot –pmypassword < mydatabase.sql
It works.