ERROR 1049 (42000): Unknown database 'mydatabasename'

后端 未结 12 1280
故里飘歌
故里飘歌 2020-12-14 07:27

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

相关标签:
12条回答
  • 2020-12-14 07:31

    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

    0 讨论(0)
  • 2020-12-14 07:31
    mysql -uroot -psecret mysql < mydatabase.sql
    
    0 讨论(0)
  • 2020-12-14 07:33

    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.

    0 讨论(0)
  • 2020-12-14 07:37

    when u import database from workbench or other method ,should be give same name as your dump to avoid this kind of error

    0 讨论(0)
  • 2020-12-14 07:40

    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;
    
    0 讨论(0)
  • 2020-12-14 07:40

    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;
    
    0 讨论(0)
提交回复
热议问题