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
Whatever the name of your dump file, it's the content which does matter.
You need to check your mydatabase.sql
and find this line :
USE mydatabasename;
This name does matter, and it's the one you must use in your command :
mysql -uroot -pmypassword mydatabasename
Two options for you :
USE mydatabasename;
in your dump, and keep using :mysql -uroot -pmypassword mydatabase
mysql -uroot -pmypassword mydatabasename