Problem in accessing to Mysql





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have installed and reinstalled more times Mysql, but the program deny me always the access saying:



ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)



Event if I use the real password, there's no way to get into Mysql. Any suggestion? I'm thinking there's a problem with Grants, by I have no method see them, because they are in Mysql.










share|improve this question







New contributor




GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Did you tried to access without password? Typing only mysql ou mysql database_name? This is the new behaviour on newer versions (at least for MariaDB).

    – JucaPirama
    6 hours ago











  • How did you install mySQL?

    – FloT
    5 hours ago











  • I have installed mysql writing sudo apt-get install mysql-server, and then: sudo mysql_secure_installation.

    – GenginsKant
    5 hours ago


















1















I have installed and reinstalled more times Mysql, but the program deny me always the access saying:



ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)



Event if I use the real password, there's no way to get into Mysql. Any suggestion? I'm thinking there's a problem with Grants, by I have no method see them, because they are in Mysql.










share|improve this question







New contributor




GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Did you tried to access without password? Typing only mysql ou mysql database_name? This is the new behaviour on newer versions (at least for MariaDB).

    – JucaPirama
    6 hours ago











  • How did you install mySQL?

    – FloT
    5 hours ago











  • I have installed mysql writing sudo apt-get install mysql-server, and then: sudo mysql_secure_installation.

    – GenginsKant
    5 hours ago














1












1








1








I have installed and reinstalled more times Mysql, but the program deny me always the access saying:



ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)



Event if I use the real password, there's no way to get into Mysql. Any suggestion? I'm thinking there's a problem with Grants, by I have no method see them, because they are in Mysql.










share|improve this question







New contributor




GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have installed and reinstalled more times Mysql, but the program deny me always the access saying:



ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)



Event if I use the real password, there's no way to get into Mysql. Any suggestion? I'm thinking there's a problem with Grants, by I have no method see them, because they are in Mysql.







permissions mysql






share|improve this question







New contributor




GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 6 hours ago









GenginsKantGenginsKant

61




61




New contributor




GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






GenginsKant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Did you tried to access without password? Typing only mysql ou mysql database_name? This is the new behaviour on newer versions (at least for MariaDB).

    – JucaPirama
    6 hours ago











  • How did you install mySQL?

    – FloT
    5 hours ago











  • I have installed mysql writing sudo apt-get install mysql-server, and then: sudo mysql_secure_installation.

    – GenginsKant
    5 hours ago



















  • Did you tried to access without password? Typing only mysql ou mysql database_name? This is the new behaviour on newer versions (at least for MariaDB).

    – JucaPirama
    6 hours ago











  • How did you install mySQL?

    – FloT
    5 hours ago











  • I have installed mysql writing sudo apt-get install mysql-server, and then: sudo mysql_secure_installation.

    – GenginsKant
    5 hours ago

















Did you tried to access without password? Typing only mysql ou mysql database_name? This is the new behaviour on newer versions (at least for MariaDB).

– JucaPirama
6 hours ago





Did you tried to access without password? Typing only mysql ou mysql database_name? This is the new behaviour on newer versions (at least for MariaDB).

– JucaPirama
6 hours ago













How did you install mySQL?

– FloT
5 hours ago





How did you install mySQL?

– FloT
5 hours ago













I have installed mysql writing sudo apt-get install mysql-server, and then: sudo mysql_secure_installation.

– GenginsKant
5 hours ago





I have installed mysql writing sudo apt-get install mysql-server, and then: sudo mysql_secure_installation.

– GenginsKant
5 hours ago










2 Answers
2






active

oldest

votes


















0














If you have installed mySQL from Ubuntu repository, the authentication of root user is not possible as usual with mysql -u root -p.



Instead, you have to type sudo mysql and the terminal will prompt you with your sudo password.



That should solve your problem and allow you to connect mySQL.



I had the same issue recently and I preferred getting back usual mysql -u root -p method (also easier to configure some tools e.g. mySQL Workbench, DBeaver...). Here are the steps I followed to get this done:



Connect to mySQL



sudo mysql


Create an admin account



CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;


You can stop here and use the admin user instead of root. They basically have the same access rights.



If you prefer to come back to root user, you can follow the steps below:
Quit root connection and reconnect with new admin account:



quit; /* mySQL will tell you "Bye" */
mysql -u admin -p


Remove root user



drop user root@localhost;


Re-create root user with usual authentication method



CREATE USER 'root'@'localhost' IDENTIFIED BY 'the_password_you_wish_here';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;


Then disconnect, re-connect with root and delete the admin account



quit; /* mySQL will tell you "Bye" */
mysql -u root -p
drop user admin@localhost;


Now you'll be able to connect with mysql -u root -p






share|improve this answer
























  • I have tried the 'sudo mysql' but the answer is almost the same: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

    – GenginsKant
    5 hours ago











  • @GenginsKant You can refer to this answer on SO

    – Kulfy
    5 hours ago



















0














Try this step by step first remove mysql from your machine then just install it by
sudo apt-get install mysql-server you'll have ask to set a password.



sudo apt-get remove --purge mysql && sudo apt-get purge mysql && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get remove dbconfig-mysql && sudo apt-get dist-upgrade && sudo apt-get install mysql-server






share|improve this answer








New contributor




Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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',
    autoActivateHeartbeat: false,
    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
    });


    }
    });






    GenginsKant is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1131286%2fproblem-in-accessing-to-mysql%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









    0














    If you have installed mySQL from Ubuntu repository, the authentication of root user is not possible as usual with mysql -u root -p.



    Instead, you have to type sudo mysql and the terminal will prompt you with your sudo password.



    That should solve your problem and allow you to connect mySQL.



    I had the same issue recently and I preferred getting back usual mysql -u root -p method (also easier to configure some tools e.g. mySQL Workbench, DBeaver...). Here are the steps I followed to get this done:



    Connect to mySQL



    sudo mysql


    Create an admin account



    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';
    GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;


    You can stop here and use the admin user instead of root. They basically have the same access rights.



    If you prefer to come back to root user, you can follow the steps below:
    Quit root connection and reconnect with new admin account:



    quit; /* mySQL will tell you "Bye" */
    mysql -u admin -p


    Remove root user



    drop user root@localhost;


    Re-create root user with usual authentication method



    CREATE USER 'root'@'localhost' IDENTIFIED BY 'the_password_you_wish_here';
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;


    Then disconnect, re-connect with root and delete the admin account



    quit; /* mySQL will tell you "Bye" */
    mysql -u root -p
    drop user admin@localhost;


    Now you'll be able to connect with mysql -u root -p






    share|improve this answer
























    • I have tried the 'sudo mysql' but the answer is almost the same: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

      – GenginsKant
      5 hours ago











    • @GenginsKant You can refer to this answer on SO

      – Kulfy
      5 hours ago
















    0














    If you have installed mySQL from Ubuntu repository, the authentication of root user is not possible as usual with mysql -u root -p.



    Instead, you have to type sudo mysql and the terminal will prompt you with your sudo password.



    That should solve your problem and allow you to connect mySQL.



    I had the same issue recently and I preferred getting back usual mysql -u root -p method (also easier to configure some tools e.g. mySQL Workbench, DBeaver...). Here are the steps I followed to get this done:



    Connect to mySQL



    sudo mysql


    Create an admin account



    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';
    GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;


    You can stop here and use the admin user instead of root. They basically have the same access rights.



    If you prefer to come back to root user, you can follow the steps below:
    Quit root connection and reconnect with new admin account:



    quit; /* mySQL will tell you "Bye" */
    mysql -u admin -p


    Remove root user



    drop user root@localhost;


    Re-create root user with usual authentication method



    CREATE USER 'root'@'localhost' IDENTIFIED BY 'the_password_you_wish_here';
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;


    Then disconnect, re-connect with root and delete the admin account



    quit; /* mySQL will tell you "Bye" */
    mysql -u root -p
    drop user admin@localhost;


    Now you'll be able to connect with mysql -u root -p






    share|improve this answer
























    • I have tried the 'sudo mysql' but the answer is almost the same: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

      – GenginsKant
      5 hours ago











    • @GenginsKant You can refer to this answer on SO

      – Kulfy
      5 hours ago














    0












    0








    0







    If you have installed mySQL from Ubuntu repository, the authentication of root user is not possible as usual with mysql -u root -p.



    Instead, you have to type sudo mysql and the terminal will prompt you with your sudo password.



    That should solve your problem and allow you to connect mySQL.



    I had the same issue recently and I preferred getting back usual mysql -u root -p method (also easier to configure some tools e.g. mySQL Workbench, DBeaver...). Here are the steps I followed to get this done:



    Connect to mySQL



    sudo mysql


    Create an admin account



    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';
    GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;


    You can stop here and use the admin user instead of root. They basically have the same access rights.



    If you prefer to come back to root user, you can follow the steps below:
    Quit root connection and reconnect with new admin account:



    quit; /* mySQL will tell you "Bye" */
    mysql -u admin -p


    Remove root user



    drop user root@localhost;


    Re-create root user with usual authentication method



    CREATE USER 'root'@'localhost' IDENTIFIED BY 'the_password_you_wish_here';
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;


    Then disconnect, re-connect with root and delete the admin account



    quit; /* mySQL will tell you "Bye" */
    mysql -u root -p
    drop user admin@localhost;


    Now you'll be able to connect with mysql -u root -p






    share|improve this answer













    If you have installed mySQL from Ubuntu repository, the authentication of root user is not possible as usual with mysql -u root -p.



    Instead, you have to type sudo mysql and the terminal will prompt you with your sudo password.



    That should solve your problem and allow you to connect mySQL.



    I had the same issue recently and I preferred getting back usual mysql -u root -p method (also easier to configure some tools e.g. mySQL Workbench, DBeaver...). Here are the steps I followed to get this done:



    Connect to mySQL



    sudo mysql


    Create an admin account



    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';
    GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;


    You can stop here and use the admin user instead of root. They basically have the same access rights.



    If you prefer to come back to root user, you can follow the steps below:
    Quit root connection and reconnect with new admin account:



    quit; /* mySQL will tell you "Bye" */
    mysql -u admin -p


    Remove root user



    drop user root@localhost;


    Re-create root user with usual authentication method



    CREATE USER 'root'@'localhost' IDENTIFIED BY 'the_password_you_wish_here';
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;


    Then disconnect, re-connect with root and delete the admin account



    quit; /* mySQL will tell you "Bye" */
    mysql -u root -p
    drop user admin@localhost;


    Now you'll be able to connect with mysql -u root -p







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 5 hours ago









    FloTFloT

    688117




    688117













    • I have tried the 'sudo mysql' but the answer is almost the same: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

      – GenginsKant
      5 hours ago











    • @GenginsKant You can refer to this answer on SO

      – Kulfy
      5 hours ago



















    • I have tried the 'sudo mysql' but the answer is almost the same: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

      – GenginsKant
      5 hours ago











    • @GenginsKant You can refer to this answer on SO

      – Kulfy
      5 hours ago

















    I have tried the 'sudo mysql' but the answer is almost the same: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

    – GenginsKant
    5 hours ago





    I have tried the 'sudo mysql' but the answer is almost the same: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

    – GenginsKant
    5 hours ago













    @GenginsKant You can refer to this answer on SO

    – Kulfy
    5 hours ago





    @GenginsKant You can refer to this answer on SO

    – Kulfy
    5 hours ago













    0














    Try this step by step first remove mysql from your machine then just install it by
    sudo apt-get install mysql-server you'll have ask to set a password.



    sudo apt-get remove --purge mysql && sudo apt-get purge mysql && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get remove dbconfig-mysql && sudo apt-get dist-upgrade && sudo apt-get install mysql-server






    share|improve this answer








    New contributor




    Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      Try this step by step first remove mysql from your machine then just install it by
      sudo apt-get install mysql-server you'll have ask to set a password.



      sudo apt-get remove --purge mysql && sudo apt-get purge mysql && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get remove dbconfig-mysql && sudo apt-get dist-upgrade && sudo apt-get install mysql-server






      share|improve this answer








      New contributor




      Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        Try this step by step first remove mysql from your machine then just install it by
        sudo apt-get install mysql-server you'll have ask to set a password.



        sudo apt-get remove --purge mysql && sudo apt-get purge mysql && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get remove dbconfig-mysql && sudo apt-get dist-upgrade && sudo apt-get install mysql-server






        share|improve this answer








        New contributor




        Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        Try this step by step first remove mysql from your machine then just install it by
        sudo apt-get install mysql-server you'll have ask to set a password.



        sudo apt-get remove --purge mysql && sudo apt-get purge mysql && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get remove dbconfig-mysql && sudo apt-get dist-upgrade && sudo apt-get install mysql-server







        share|improve this answer








        New contributor




        Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 1 hour ago









        Mishuk AdhikariMishuk Adhikari

        211




        211




        New contributor




        Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Mishuk Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






















            GenginsKant is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            GenginsKant is a new contributor. Be nice, and check out our Code of Conduct.













            GenginsKant is a new contributor. Be nice, and check out our Code of Conduct.












            GenginsKant is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f1131286%2fproblem-in-accessing-to-mysql%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

            GameSpot

            connect to host localhost port 22: Connection refused

            Getting a Wifi WPA2 wifi connection