Xampp: cannot connect to mysql from terminal

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












I added export PATH=$PATH:/opt/lampp/bin/ to my ~/.zshrc file. I can access php but whenever I type sudo mysql -uroot I see the following message:




ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)




I can however, access mysql by defining full path like this: sudo /opt/lampp/bin/mysql -uroot. But I don't want that... I mean I would have to type the full path everytime or create an alias or symlink.



I am on Ubuntu 16.04 and using zshell.










share|improve this question

















  • 1




    Any particular reason to run XAMPP and not our native version? Ours is tailored to Ubuntu works out of the box and has lots more documentation. Plus the owner of XAMPP himself admitted that it is not fit for serious usage.
    – Rinzwind
    Feb 1 at 8:29










  • sudo uses its own secure_path rather than the invoking user's path. Do you really need to run mysql as root (as opposed to logging in to it with the mysql root user)?
    – steeldriver
    Feb 1 at 11:07














up vote
1
down vote

favorite












I added export PATH=$PATH:/opt/lampp/bin/ to my ~/.zshrc file. I can access php but whenever I type sudo mysql -uroot I see the following message:




ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)




I can however, access mysql by defining full path like this: sudo /opt/lampp/bin/mysql -uroot. But I don't want that... I mean I would have to type the full path everytime or create an alias or symlink.



I am on Ubuntu 16.04 and using zshell.










share|improve this question

















  • 1




    Any particular reason to run XAMPP and not our native version? Ours is tailored to Ubuntu works out of the box and has lots more documentation. Plus the owner of XAMPP himself admitted that it is not fit for serious usage.
    – Rinzwind
    Feb 1 at 8:29










  • sudo uses its own secure_path rather than the invoking user's path. Do you really need to run mysql as root (as opposed to logging in to it with the mysql root user)?
    – steeldriver
    Feb 1 at 11:07












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I added export PATH=$PATH:/opt/lampp/bin/ to my ~/.zshrc file. I can access php but whenever I type sudo mysql -uroot I see the following message:




ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)




I can however, access mysql by defining full path like this: sudo /opt/lampp/bin/mysql -uroot. But I don't want that... I mean I would have to type the full path everytime or create an alias or symlink.



I am on Ubuntu 16.04 and using zshell.










share|improve this question













I added export PATH=$PATH:/opt/lampp/bin/ to my ~/.zshrc file. I can access php but whenever I type sudo mysql -uroot I see the following message:




ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)




I can however, access mysql by defining full path like this: sudo /opt/lampp/bin/mysql -uroot. But I don't want that... I mean I would have to type the full path everytime or create an alias or symlink.



I am on Ubuntu 16.04 and using zshell.







mysql xampp






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 1 at 6:09









Eisenheim

2192310




2192310







  • 1




    Any particular reason to run XAMPP and not our native version? Ours is tailored to Ubuntu works out of the box and has lots more documentation. Plus the owner of XAMPP himself admitted that it is not fit for serious usage.
    – Rinzwind
    Feb 1 at 8:29










  • sudo uses its own secure_path rather than the invoking user's path. Do you really need to run mysql as root (as opposed to logging in to it with the mysql root user)?
    – steeldriver
    Feb 1 at 11:07












  • 1




    Any particular reason to run XAMPP and not our native version? Ours is tailored to Ubuntu works out of the box and has lots more documentation. Plus the owner of XAMPP himself admitted that it is not fit for serious usage.
    – Rinzwind
    Feb 1 at 8:29










  • sudo uses its own secure_path rather than the invoking user's path. Do you really need to run mysql as root (as opposed to logging in to it with the mysql root user)?
    – steeldriver
    Feb 1 at 11:07







1




1




Any particular reason to run XAMPP and not our native version? Ours is tailored to Ubuntu works out of the box and has lots more documentation. Plus the owner of XAMPP himself admitted that it is not fit for serious usage.
– Rinzwind
Feb 1 at 8:29




Any particular reason to run XAMPP and not our native version? Ours is tailored to Ubuntu works out of the box and has lots more documentation. Plus the owner of XAMPP himself admitted that it is not fit for serious usage.
– Rinzwind
Feb 1 at 8:29












sudo uses its own secure_path rather than the invoking user's path. Do you really need to run mysql as root (as opposed to logging in to it with the mysql root user)?
– steeldriver
Feb 1 at 11:07




sudo uses its own secure_path rather than the invoking user's path. Do you really need to run mysql as root (as opposed to logging in to it with the mysql root user)?
– steeldriver
Feb 1 at 11:07










1 Answer
1






active

oldest

votes

















up vote
1
down vote













You have two versions of mysql installed - one from Ubuntu repositories and one from some third party location. When you use the Ubuntu version, located in /usr/bin/mysql it attempt to connect trough a socket in the default location, /var/run/mysqld/mysqld.sock, which does not work, because the server running is not the Ubuntu stock mysql-server.



It works when you run /opt/lampp/bin/mysql -uroot (no reason to run that as root, by the way), because this mysql binary has default path set to where the actual socket is.



You have three alternatives:



  1. Modify your path so that /opt/lampp/bin/ is before/usr/bin/` in path. This will execute the lampp version of mysql before the Ubuntu version.

  2. Uninstall Ubuntu mysql client with sudo apt-get remove mysql-client. This may break other packages.

  3. Uninstall lampp and install the required packages from Ubuntu.

#3 would be my preferred solution. Getting all the software from the repositories ensures that it will be kept up to date, be (mostly) compatible, and have a clear, well defined upgrade path to the next Ubuntu Release.



Apache, PHP, Mysql/MariaDB and a lot of apache modules are available in the Ubuntu repositories.






share|improve this answer




















    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1001962%2fxampp-cannot-connect-to-mysql-from-terminal%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    You have two versions of mysql installed - one from Ubuntu repositories and one from some third party location. When you use the Ubuntu version, located in /usr/bin/mysql it attempt to connect trough a socket in the default location, /var/run/mysqld/mysqld.sock, which does not work, because the server running is not the Ubuntu stock mysql-server.



    It works when you run /opt/lampp/bin/mysql -uroot (no reason to run that as root, by the way), because this mysql binary has default path set to where the actual socket is.



    You have three alternatives:



    1. Modify your path so that /opt/lampp/bin/ is before/usr/bin/` in path. This will execute the lampp version of mysql before the Ubuntu version.

    2. Uninstall Ubuntu mysql client with sudo apt-get remove mysql-client. This may break other packages.

    3. Uninstall lampp and install the required packages from Ubuntu.

    #3 would be my preferred solution. Getting all the software from the repositories ensures that it will be kept up to date, be (mostly) compatible, and have a clear, well defined upgrade path to the next Ubuntu Release.



    Apache, PHP, Mysql/MariaDB and a lot of apache modules are available in the Ubuntu repositories.






    share|improve this answer
























      up vote
      1
      down vote













      You have two versions of mysql installed - one from Ubuntu repositories and one from some third party location. When you use the Ubuntu version, located in /usr/bin/mysql it attempt to connect trough a socket in the default location, /var/run/mysqld/mysqld.sock, which does not work, because the server running is not the Ubuntu stock mysql-server.



      It works when you run /opt/lampp/bin/mysql -uroot (no reason to run that as root, by the way), because this mysql binary has default path set to where the actual socket is.



      You have three alternatives:



      1. Modify your path so that /opt/lampp/bin/ is before/usr/bin/` in path. This will execute the lampp version of mysql before the Ubuntu version.

      2. Uninstall Ubuntu mysql client with sudo apt-get remove mysql-client. This may break other packages.

      3. Uninstall lampp and install the required packages from Ubuntu.

      #3 would be my preferred solution. Getting all the software from the repositories ensures that it will be kept up to date, be (mostly) compatible, and have a clear, well defined upgrade path to the next Ubuntu Release.



      Apache, PHP, Mysql/MariaDB and a lot of apache modules are available in the Ubuntu repositories.






      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        You have two versions of mysql installed - one from Ubuntu repositories and one from some third party location. When you use the Ubuntu version, located in /usr/bin/mysql it attempt to connect trough a socket in the default location, /var/run/mysqld/mysqld.sock, which does not work, because the server running is not the Ubuntu stock mysql-server.



        It works when you run /opt/lampp/bin/mysql -uroot (no reason to run that as root, by the way), because this mysql binary has default path set to where the actual socket is.



        You have three alternatives:



        1. Modify your path so that /opt/lampp/bin/ is before/usr/bin/` in path. This will execute the lampp version of mysql before the Ubuntu version.

        2. Uninstall Ubuntu mysql client with sudo apt-get remove mysql-client. This may break other packages.

        3. Uninstall lampp and install the required packages from Ubuntu.

        #3 would be my preferred solution. Getting all the software from the repositories ensures that it will be kept up to date, be (mostly) compatible, and have a clear, well defined upgrade path to the next Ubuntu Release.



        Apache, PHP, Mysql/MariaDB and a lot of apache modules are available in the Ubuntu repositories.






        share|improve this answer












        You have two versions of mysql installed - one from Ubuntu repositories and one from some third party location. When you use the Ubuntu version, located in /usr/bin/mysql it attempt to connect trough a socket in the default location, /var/run/mysqld/mysqld.sock, which does not work, because the server running is not the Ubuntu stock mysql-server.



        It works when you run /opt/lampp/bin/mysql -uroot (no reason to run that as root, by the way), because this mysql binary has default path set to where the actual socket is.



        You have three alternatives:



        1. Modify your path so that /opt/lampp/bin/ is before/usr/bin/` in path. This will execute the lampp version of mysql before the Ubuntu version.

        2. Uninstall Ubuntu mysql client with sudo apt-get remove mysql-client. This may break other packages.

        3. Uninstall lampp and install the required packages from Ubuntu.

        #3 would be my preferred solution. Getting all the software from the repositories ensures that it will be kept up to date, be (mostly) compatible, and have a clear, well defined upgrade path to the next Ubuntu Release.



        Apache, PHP, Mysql/MariaDB and a lot of apache modules are available in the Ubuntu repositories.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 1 at 7:46









        vidarlo

        7,26642140




        7,26642140



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1001962%2fxampp-cannot-connect-to-mysql-from-terminal%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491