Error: SQLSTATE[HY000] [1049] Unknown database











up vote
0
down vote

favorite












I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.



It says




"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"




The sql file is correctly named "otkrica" and my db.php looks like this:



<?php 
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";

try{

$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>


I would really appreciate input on this one. What am I missing?










share|improve this question




















  • 2




    Have you actually created a database named otkrica?
    – eggyal
    Sep 1 '16 at 17:58










  • be sure you don't have more then one mysql installation. Try to set the port you are using like: mysql:host=localhost;port=3307;dbname=testdb
    – cmnardi
    Sep 1 '16 at 18:03












  • Yes, I did. It's in my project root folder and db.php is in root/core folder.
    – Strahinjatronic
    Sep 1 '16 at 18:05










  • this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
    – cmnardi
    Sep 1 '16 at 18:08










  • That did it. Thank you!
    – Strahinjatronic
    Sep 1 '16 at 19:06















up vote
0
down vote

favorite












I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.



It says




"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"




The sql file is correctly named "otkrica" and my db.php looks like this:



<?php 
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";

try{

$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>


I would really appreciate input on this one. What am I missing?










share|improve this question




















  • 2




    Have you actually created a database named otkrica?
    – eggyal
    Sep 1 '16 at 17:58










  • be sure you don't have more then one mysql installation. Try to set the port you are using like: mysql:host=localhost;port=3307;dbname=testdb
    – cmnardi
    Sep 1 '16 at 18:03












  • Yes, I did. It's in my project root folder and db.php is in root/core folder.
    – Strahinjatronic
    Sep 1 '16 at 18:05










  • this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
    – cmnardi
    Sep 1 '16 at 18:08










  • That did it. Thank you!
    – Strahinjatronic
    Sep 1 '16 at 19:06













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.



It says




"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"




The sql file is correctly named "otkrica" and my db.php looks like this:



<?php 
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";

try{

$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>


I would really appreciate input on this one. What am I missing?










share|improve this question















I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.



It says




"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"




The sql file is correctly named "otkrica" and my db.php looks like this:



<?php 
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";

try{

$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>


I would really appreciate input on this one. What am I missing?







php mysql pdo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 1 '16 at 17:57









Qirel

9,54862337




9,54862337










asked Sep 1 '16 at 17:56









Strahinjatronic

614




614








  • 2




    Have you actually created a database named otkrica?
    – eggyal
    Sep 1 '16 at 17:58










  • be sure you don't have more then one mysql installation. Try to set the port you are using like: mysql:host=localhost;port=3307;dbname=testdb
    – cmnardi
    Sep 1 '16 at 18:03












  • Yes, I did. It's in my project root folder and db.php is in root/core folder.
    – Strahinjatronic
    Sep 1 '16 at 18:05










  • this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
    – cmnardi
    Sep 1 '16 at 18:08










  • That did it. Thank you!
    – Strahinjatronic
    Sep 1 '16 at 19:06














  • 2




    Have you actually created a database named otkrica?
    – eggyal
    Sep 1 '16 at 17:58










  • be sure you don't have more then one mysql installation. Try to set the port you are using like: mysql:host=localhost;port=3307;dbname=testdb
    – cmnardi
    Sep 1 '16 at 18:03












  • Yes, I did. It's in my project root folder and db.php is in root/core folder.
    – Strahinjatronic
    Sep 1 '16 at 18:05










  • this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
    – cmnardi
    Sep 1 '16 at 18:08










  • That did it. Thank you!
    – Strahinjatronic
    Sep 1 '16 at 19:06








2




2




Have you actually created a database named otkrica?
– eggyal
Sep 1 '16 at 17:58




Have you actually created a database named otkrica?
– eggyal
Sep 1 '16 at 17:58












be sure you don't have more then one mysql installation. Try to set the port you are using like: mysql:host=localhost;port=3307;dbname=testdb
– cmnardi
Sep 1 '16 at 18:03






be sure you don't have more then one mysql installation. Try to set the port you are using like: mysql:host=localhost;port=3307;dbname=testdb
– cmnardi
Sep 1 '16 at 18:03














Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05




Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05












this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08




this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08












That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06




That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06












2 Answers
2






active

oldest

votes

















up vote
0
down vote













Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
Select that database while Importing. Thank you.



New Database section in phpMyAdmin






share|improve this answer




























    up vote
    0
    down vote













    I fix this problem wait this way



    enter image description here



    attention: use as wampserver ver2.5 for build database in the server
    after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.






    share|improve this answer

















    • 1




      Do not post images as an answer to the question.
      – Vineeth Sai
      Nov 11 at 7:48













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39278057%2ferror-sqlstatehy000-1049-unknown-database%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
    Select that database while Importing. Thank you.



    New Database section in phpMyAdmin






    share|improve this answer

























      up vote
      0
      down vote













      Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
      Select that database while Importing. Thank you.



      New Database section in phpMyAdmin






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
        Select that database while Importing. Thank you.



        New Database section in phpMyAdmin






        share|improve this answer












        Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
        Select that database while Importing. Thank you.



        New Database section in phpMyAdmin







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 4 at 10:25









        Sharan Salian

        76




        76
























            up vote
            0
            down vote













            I fix this problem wait this way



            enter image description here



            attention: use as wampserver ver2.5 for build database in the server
            after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.






            share|improve this answer

















            • 1




              Do not post images as an answer to the question.
              – Vineeth Sai
              Nov 11 at 7:48

















            up vote
            0
            down vote













            I fix this problem wait this way



            enter image description here



            attention: use as wampserver ver2.5 for build database in the server
            after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.






            share|improve this answer

















            • 1




              Do not post images as an answer to the question.
              – Vineeth Sai
              Nov 11 at 7:48















            up vote
            0
            down vote










            up vote
            0
            down vote









            I fix this problem wait this way



            enter image description here



            attention: use as wampserver ver2.5 for build database in the server
            after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.






            share|improve this answer












            I fix this problem wait this way



            enter image description here



            attention: use as wampserver ver2.5 for build database in the server
            after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 11 at 7:41









            Reza

            45




            45








            • 1




              Do not post images as an answer to the question.
              – Vineeth Sai
              Nov 11 at 7:48
















            • 1




              Do not post images as an answer to the question.
              – Vineeth Sai
              Nov 11 at 7:48










            1




            1




            Do not post images as an answer to the question.
            – Vineeth Sai
            Nov 11 at 7:48






            Do not post images as an answer to the question.
            – Vineeth Sai
            Nov 11 at 7:48




















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39278057%2ferror-sqlstatehy000-1049-unknown-database%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Coverage of Google Street View

            Full-time equivalent

            Surfing