Can't connect to local MySQL server through socket '/tmp/mysql_2.sock' during manual installation of mysql











up vote
1
down vote

favorite












I get the error below when attempting to manually install mysql-5.6.17-linux-glibc2.5-x86_64



Steps I followed:



1. tar -xzvf mysql-standard-5.1.34-linux-i686-glibc23.tar.gz
2. ln -s mysql-standard-5.1.34-linux-i686-glibc23 mysql
a) set basedir= to the full path of your new mysql directory
b) set datadir= to the full path of the /data subdir in your new mysql directory.
3. Set up the default MySQL databases:
a) ./scripts/mysql_install_db --defaults-file=mysql.cnf
b) ./bin/mysqladmin --defaults-file=mysql.cnf -u root password "yourpasswordhere"
4. Create a New Database and User Account
a) Log in to your mysql server as root: ./bin/mysql --defaults-file=mysql.cnf -u root -p


mysql.cnf file looks like:



[client]
socket=/tmp/mysql_2.sock
port=3307
####################################
[mysqld]
#REQUIRED!!
#Change the basedir directory to reflect your mysql home directory
basedir=/mysql
#REQUIRED!!
#Change the data direcory to reflect your mysql data directory
datadir=/mysql/data
port=3307
socket=/tmp/mysql_2.sock
key_buffer_size=64M

#[OPTIMIZATION]
#Set this value to 50% of available RAM if your environment permits.
myisam_sort_buffer_size=1.5G
#[OPTIMIZATION]
#This value should be at least 50% of free hard drive space. Use caution if setting it to 100% of free space however. Your hard disk may fill up!
myisam_max_sort_file_size=100G

#[OPTIMIZATION]
#Our default of 2G is probably fine for this value. Change this value only if you are using a machine with little resources available.
read_buffer_size=1.5G


command:



root@ubuntu:/mysql#  ./bin/mysqld_safe --defaults-    file=mysql.cnf &  


Error:



[1] 2386
root@ubuntu:/mysql# 140415 19:08:12 mysqld_safe Logging to '/mysql/data/ubuntu.err'.
chown: invalid user: `mysql'
140415 19:08:12 mysqld_safe Starting mysqld daemon with databases from /mysql/data
140415 19:08:12 mysqld_safe mysqld from pid file /mysql/data/ubuntu.pid ended

./bin/mysqladmin --defaults-file=mysql.cnf -u
./bin/mysqladmin --defaults-file=mysql.cnf -u root password 12345
./bin/mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysql_2.sock' (2)'

Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!
[1]+ Done ./bin/mysqld_safe --defaults-file=mysql.cnf


I tried to login by command:



./bin/mysql --defaults-file=mysql.cnf -u root -p  


Error:



Enter password:   

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









share|improve this question
























  • "Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!"
    – Rinzwind
    Apr 15 '14 at 14:29










  • You need to tell us what you've done to install it. For example, you seem not to have created the mysql user who is apparently needed: chown: invalid user: mysql'`
    – terdon
    Apr 15 '14 at 14:31










  • @Rinzwind '/tmp/mysql_2.sock' does not exist. How to check is mysqld working?
    – BioDeveloper
    Apr 15 '14 at 14:31












  • @terdon I am trying to create a New Database and User Account. login to it and create a new schema.
    – BioDeveloper
    Apr 15 '14 at 14:35










  • @nari2 that should be a question you should not need to ask. ps -ef | grep mysql would be my choice. By the way: if the socket is not created you probably have permissions problems.
    – Rinzwind
    Apr 15 '14 at 14:41

















up vote
1
down vote

favorite












I get the error below when attempting to manually install mysql-5.6.17-linux-glibc2.5-x86_64



Steps I followed:



1. tar -xzvf mysql-standard-5.1.34-linux-i686-glibc23.tar.gz
2. ln -s mysql-standard-5.1.34-linux-i686-glibc23 mysql
a) set basedir= to the full path of your new mysql directory
b) set datadir= to the full path of the /data subdir in your new mysql directory.
3. Set up the default MySQL databases:
a) ./scripts/mysql_install_db --defaults-file=mysql.cnf
b) ./bin/mysqladmin --defaults-file=mysql.cnf -u root password "yourpasswordhere"
4. Create a New Database and User Account
a) Log in to your mysql server as root: ./bin/mysql --defaults-file=mysql.cnf -u root -p


mysql.cnf file looks like:



[client]
socket=/tmp/mysql_2.sock
port=3307
####################################
[mysqld]
#REQUIRED!!
#Change the basedir directory to reflect your mysql home directory
basedir=/mysql
#REQUIRED!!
#Change the data direcory to reflect your mysql data directory
datadir=/mysql/data
port=3307
socket=/tmp/mysql_2.sock
key_buffer_size=64M

#[OPTIMIZATION]
#Set this value to 50% of available RAM if your environment permits.
myisam_sort_buffer_size=1.5G
#[OPTIMIZATION]
#This value should be at least 50% of free hard drive space. Use caution if setting it to 100% of free space however. Your hard disk may fill up!
myisam_max_sort_file_size=100G

#[OPTIMIZATION]
#Our default of 2G is probably fine for this value. Change this value only if you are using a machine with little resources available.
read_buffer_size=1.5G


command:



root@ubuntu:/mysql#  ./bin/mysqld_safe --defaults-    file=mysql.cnf &  


Error:



[1] 2386
root@ubuntu:/mysql# 140415 19:08:12 mysqld_safe Logging to '/mysql/data/ubuntu.err'.
chown: invalid user: `mysql'
140415 19:08:12 mysqld_safe Starting mysqld daemon with databases from /mysql/data
140415 19:08:12 mysqld_safe mysqld from pid file /mysql/data/ubuntu.pid ended

./bin/mysqladmin --defaults-file=mysql.cnf -u
./bin/mysqladmin --defaults-file=mysql.cnf -u root password 12345
./bin/mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysql_2.sock' (2)'

Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!
[1]+ Done ./bin/mysqld_safe --defaults-file=mysql.cnf


I tried to login by command:



./bin/mysql --defaults-file=mysql.cnf -u root -p  


Error:



Enter password:   

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









share|improve this question
























  • "Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!"
    – Rinzwind
    Apr 15 '14 at 14:29










  • You need to tell us what you've done to install it. For example, you seem not to have created the mysql user who is apparently needed: chown: invalid user: mysql'`
    – terdon
    Apr 15 '14 at 14:31










  • @Rinzwind '/tmp/mysql_2.sock' does not exist. How to check is mysqld working?
    – BioDeveloper
    Apr 15 '14 at 14:31












  • @terdon I am trying to create a New Database and User Account. login to it and create a new schema.
    – BioDeveloper
    Apr 15 '14 at 14:35










  • @nari2 that should be a question you should not need to ask. ps -ef | grep mysql would be my choice. By the way: if the socket is not created you probably have permissions problems.
    – Rinzwind
    Apr 15 '14 at 14:41















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I get the error below when attempting to manually install mysql-5.6.17-linux-glibc2.5-x86_64



Steps I followed:



1. tar -xzvf mysql-standard-5.1.34-linux-i686-glibc23.tar.gz
2. ln -s mysql-standard-5.1.34-linux-i686-glibc23 mysql
a) set basedir= to the full path of your new mysql directory
b) set datadir= to the full path of the /data subdir in your new mysql directory.
3. Set up the default MySQL databases:
a) ./scripts/mysql_install_db --defaults-file=mysql.cnf
b) ./bin/mysqladmin --defaults-file=mysql.cnf -u root password "yourpasswordhere"
4. Create a New Database and User Account
a) Log in to your mysql server as root: ./bin/mysql --defaults-file=mysql.cnf -u root -p


mysql.cnf file looks like:



[client]
socket=/tmp/mysql_2.sock
port=3307
####################################
[mysqld]
#REQUIRED!!
#Change the basedir directory to reflect your mysql home directory
basedir=/mysql
#REQUIRED!!
#Change the data direcory to reflect your mysql data directory
datadir=/mysql/data
port=3307
socket=/tmp/mysql_2.sock
key_buffer_size=64M

#[OPTIMIZATION]
#Set this value to 50% of available RAM if your environment permits.
myisam_sort_buffer_size=1.5G
#[OPTIMIZATION]
#This value should be at least 50% of free hard drive space. Use caution if setting it to 100% of free space however. Your hard disk may fill up!
myisam_max_sort_file_size=100G

#[OPTIMIZATION]
#Our default of 2G is probably fine for this value. Change this value only if you are using a machine with little resources available.
read_buffer_size=1.5G


command:



root@ubuntu:/mysql#  ./bin/mysqld_safe --defaults-    file=mysql.cnf &  


Error:



[1] 2386
root@ubuntu:/mysql# 140415 19:08:12 mysqld_safe Logging to '/mysql/data/ubuntu.err'.
chown: invalid user: `mysql'
140415 19:08:12 mysqld_safe Starting mysqld daemon with databases from /mysql/data
140415 19:08:12 mysqld_safe mysqld from pid file /mysql/data/ubuntu.pid ended

./bin/mysqladmin --defaults-file=mysql.cnf -u
./bin/mysqladmin --defaults-file=mysql.cnf -u root password 12345
./bin/mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysql_2.sock' (2)'

Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!
[1]+ Done ./bin/mysqld_safe --defaults-file=mysql.cnf


I tried to login by command:



./bin/mysql --defaults-file=mysql.cnf -u root -p  


Error:



Enter password:   

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









share|improve this question















I get the error below when attempting to manually install mysql-5.6.17-linux-glibc2.5-x86_64



Steps I followed:



1. tar -xzvf mysql-standard-5.1.34-linux-i686-glibc23.tar.gz
2. ln -s mysql-standard-5.1.34-linux-i686-glibc23 mysql
a) set basedir= to the full path of your new mysql directory
b) set datadir= to the full path of the /data subdir in your new mysql directory.
3. Set up the default MySQL databases:
a) ./scripts/mysql_install_db --defaults-file=mysql.cnf
b) ./bin/mysqladmin --defaults-file=mysql.cnf -u root password "yourpasswordhere"
4. Create a New Database and User Account
a) Log in to your mysql server as root: ./bin/mysql --defaults-file=mysql.cnf -u root -p


mysql.cnf file looks like:



[client]
socket=/tmp/mysql_2.sock
port=3307
####################################
[mysqld]
#REQUIRED!!
#Change the basedir directory to reflect your mysql home directory
basedir=/mysql
#REQUIRED!!
#Change the data direcory to reflect your mysql data directory
datadir=/mysql/data
port=3307
socket=/tmp/mysql_2.sock
key_buffer_size=64M

#[OPTIMIZATION]
#Set this value to 50% of available RAM if your environment permits.
myisam_sort_buffer_size=1.5G
#[OPTIMIZATION]
#This value should be at least 50% of free hard drive space. Use caution if setting it to 100% of free space however. Your hard disk may fill up!
myisam_max_sort_file_size=100G

#[OPTIMIZATION]
#Our default of 2G is probably fine for this value. Change this value only if you are using a machine with little resources available.
read_buffer_size=1.5G


command:



root@ubuntu:/mysql#  ./bin/mysqld_safe --defaults-    file=mysql.cnf &  


Error:



[1] 2386
root@ubuntu:/mysql# 140415 19:08:12 mysqld_safe Logging to '/mysql/data/ubuntu.err'.
chown: invalid user: `mysql'
140415 19:08:12 mysqld_safe Starting mysqld daemon with databases from /mysql/data
140415 19:08:12 mysqld_safe mysqld from pid file /mysql/data/ubuntu.pid ended

./bin/mysqladmin --defaults-file=mysql.cnf -u
./bin/mysqladmin --defaults-file=mysql.cnf -u root password 12345
./bin/mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysql_2.sock' (2)'

Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!
[1]+ Done ./bin/mysqld_safe --defaults-file=mysql.cnf


I tried to login by command:



./bin/mysql --defaults-file=mysql.cnf -u root -p  


Error:



Enter password:   

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






mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 16 '14 at 5:48

























asked Apr 15 '14 at 14:04









BioDeveloper

11817




11817












  • "Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!"
    – Rinzwind
    Apr 15 '14 at 14:29










  • You need to tell us what you've done to install it. For example, you seem not to have created the mysql user who is apparently needed: chown: invalid user: mysql'`
    – terdon
    Apr 15 '14 at 14:31










  • @Rinzwind '/tmp/mysql_2.sock' does not exist. How to check is mysqld working?
    – BioDeveloper
    Apr 15 '14 at 14:31












  • @terdon I am trying to create a New Database and User Account. login to it and create a new schema.
    – BioDeveloper
    Apr 15 '14 at 14:35










  • @nari2 that should be a question you should not need to ask. ps -ef | grep mysql would be my choice. By the way: if the socket is not created you probably have permissions problems.
    – Rinzwind
    Apr 15 '14 at 14:41




















  • "Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!"
    – Rinzwind
    Apr 15 '14 at 14:29










  • You need to tell us what you've done to install it. For example, you seem not to have created the mysql user who is apparently needed: chown: invalid user: mysql'`
    – terdon
    Apr 15 '14 at 14:31










  • @Rinzwind '/tmp/mysql_2.sock' does not exist. How to check is mysqld working?
    – BioDeveloper
    Apr 15 '14 at 14:31












  • @terdon I am trying to create a New Database and User Account. login to it and create a new schema.
    – BioDeveloper
    Apr 15 '14 at 14:35










  • @nari2 that should be a question you should not need to ask. ps -ef | grep mysql would be my choice. By the way: if the socket is not created you probably have permissions problems.
    – Rinzwind
    Apr 15 '14 at 14:41


















"Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!"
– Rinzwind
Apr 15 '14 at 14:29




"Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!"
– Rinzwind
Apr 15 '14 at 14:29












You need to tell us what you've done to install it. For example, you seem not to have created the mysql user who is apparently needed: chown: invalid user: mysql'`
– terdon
Apr 15 '14 at 14:31




You need to tell us what you've done to install it. For example, you seem not to have created the mysql user who is apparently needed: chown: invalid user: mysql'`
– terdon
Apr 15 '14 at 14:31












@Rinzwind '/tmp/mysql_2.sock' does not exist. How to check is mysqld working?
– BioDeveloper
Apr 15 '14 at 14:31






@Rinzwind '/tmp/mysql_2.sock' does not exist. How to check is mysqld working?
– BioDeveloper
Apr 15 '14 at 14:31














@terdon I am trying to create a New Database and User Account. login to it and create a new schema.
– BioDeveloper
Apr 15 '14 at 14:35




@terdon I am trying to create a New Database and User Account. login to it and create a new schema.
– BioDeveloper
Apr 15 '14 at 14:35












@nari2 that should be a question you should not need to ask. ps -ef | grep mysql would be my choice. By the way: if the socket is not created you probably have permissions problems.
– Rinzwind
Apr 15 '14 at 14:41






@nari2 that should be a question you should not need to ask. ps -ef | grep mysql would be my choice. By the way: if the socket is not created you probably have permissions problems.
– Rinzwind
Apr 15 '14 at 14:41












3 Answers
3






active

oldest

votes

















up vote
0
down vote













You should:




  1. Add a user for your mysql server useradd -r -s /bin/false -m -d /mysql mysql

  2. Write an upstart script for your server.

  3. Check that the pid file and socket files can be created by your mysql user by executing the proper chmod's.






share|improve this answer





















  • useradd: user 'mysql' already exists.
    – BioDeveloper
    Apr 16 '14 at 6:08


















up vote
0
down vote













There are a couple of steps to check when you do it manually that could create the error mentioned above. I will assume you either manually downloaded MySQL from the official site or used a 3rd party PPA to install it:





  • Check that mysql is not already running:



    ps -e|grep -i 'mysqld'.



    If it appears then you need to kill it by doing a sudo killall -9 mysqld. In the case it does not die, then grab the PID from the ps you ran and kill -9 PID




  • Run mysql via /etc/init.d/mysql start to see if it creates the same error. If it gives you the exact same error from above then you need to copy the mysql.server file which is found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and you need to copy it to /etc/init.d/mysql eg:



    cp mysql.server /etc/init.d/mysql and give it a executable permission chmod +x then try running /etc/init.d/mysql start again.



  • If it still gives you a problem then you need to edit the config file in /etc/my.cnf and change ALL the /tmp/mysql.socket lines to /var/run/mysqld/mysqld.sock or any other socket place you wish to send it. Note that the config file can also be in /etc/mysql/my.cnf in some cases like mine. The config file has at least 3 lines you need to change.







share|improve this answer





















  • mysqld not running. /etc/init.d does not contain mysql file or folder.
    – BioDeveloper
    Apr 16 '14 at 5:50










  • There you go. Now copy the mysql server script found on the downloaded tar to the init folder and give it executable permissions. Then run it.
    – Luis Alvarado
    Apr 16 '14 at 14:17


















up vote
0
down vote













If your file my.cnf (usually in the /etc/mysql/folder) is correctly configured with



 socket=/var/lib/mysql/mysql.sock


you can check if mysql is running with the following command:



 mysqladmin -u root -p status


change your permission to mysql folder. If you are working locally, you can do:



 sudo chmod -R 755 /var/lib/mysql/





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: 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%2faskubuntu.com%2fquestions%2f448094%2fcant-connect-to-local-mysql-server-through-socket-tmp-mysql-2-sock-during-ma%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    You should:




    1. Add a user for your mysql server useradd -r -s /bin/false -m -d /mysql mysql

    2. Write an upstart script for your server.

    3. Check that the pid file and socket files can be created by your mysql user by executing the proper chmod's.






    share|improve this answer





















    • useradd: user 'mysql' already exists.
      – BioDeveloper
      Apr 16 '14 at 6:08















    up vote
    0
    down vote













    You should:




    1. Add a user for your mysql server useradd -r -s /bin/false -m -d /mysql mysql

    2. Write an upstart script for your server.

    3. Check that the pid file and socket files can be created by your mysql user by executing the proper chmod's.






    share|improve this answer





















    • useradd: user 'mysql' already exists.
      – BioDeveloper
      Apr 16 '14 at 6:08













    up vote
    0
    down vote










    up vote
    0
    down vote









    You should:




    1. Add a user for your mysql server useradd -r -s /bin/false -m -d /mysql mysql

    2. Write an upstart script for your server.

    3. Check that the pid file and socket files can be created by your mysql user by executing the proper chmod's.






    share|improve this answer












    You should:




    1. Add a user for your mysql server useradd -r -s /bin/false -m -d /mysql mysql

    2. Write an upstart script for your server.

    3. Check that the pid file and socket files can be created by your mysql user by executing the proper chmod's.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 15 '14 at 15:01









    yorodm

    27612




    27612












    • useradd: user 'mysql' already exists.
      – BioDeveloper
      Apr 16 '14 at 6:08


















    • useradd: user 'mysql' already exists.
      – BioDeveloper
      Apr 16 '14 at 6:08
















    useradd: user 'mysql' already exists.
    – BioDeveloper
    Apr 16 '14 at 6:08




    useradd: user 'mysql' already exists.
    – BioDeveloper
    Apr 16 '14 at 6:08












    up vote
    0
    down vote













    There are a couple of steps to check when you do it manually that could create the error mentioned above. I will assume you either manually downloaded MySQL from the official site or used a 3rd party PPA to install it:





    • Check that mysql is not already running:



      ps -e|grep -i 'mysqld'.



      If it appears then you need to kill it by doing a sudo killall -9 mysqld. In the case it does not die, then grab the PID from the ps you ran and kill -9 PID




    • Run mysql via /etc/init.d/mysql start to see if it creates the same error. If it gives you the exact same error from above then you need to copy the mysql.server file which is found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and you need to copy it to /etc/init.d/mysql eg:



      cp mysql.server /etc/init.d/mysql and give it a executable permission chmod +x then try running /etc/init.d/mysql start again.



    • If it still gives you a problem then you need to edit the config file in /etc/my.cnf and change ALL the /tmp/mysql.socket lines to /var/run/mysqld/mysqld.sock or any other socket place you wish to send it. Note that the config file can also be in /etc/mysql/my.cnf in some cases like mine. The config file has at least 3 lines you need to change.







    share|improve this answer





















    • mysqld not running. /etc/init.d does not contain mysql file or folder.
      – BioDeveloper
      Apr 16 '14 at 5:50










    • There you go. Now copy the mysql server script found on the downloaded tar to the init folder and give it executable permissions. Then run it.
      – Luis Alvarado
      Apr 16 '14 at 14:17















    up vote
    0
    down vote













    There are a couple of steps to check when you do it manually that could create the error mentioned above. I will assume you either manually downloaded MySQL from the official site or used a 3rd party PPA to install it:





    • Check that mysql is not already running:



      ps -e|grep -i 'mysqld'.



      If it appears then you need to kill it by doing a sudo killall -9 mysqld. In the case it does not die, then grab the PID from the ps you ran and kill -9 PID




    • Run mysql via /etc/init.d/mysql start to see if it creates the same error. If it gives you the exact same error from above then you need to copy the mysql.server file which is found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and you need to copy it to /etc/init.d/mysql eg:



      cp mysql.server /etc/init.d/mysql and give it a executable permission chmod +x then try running /etc/init.d/mysql start again.



    • If it still gives you a problem then you need to edit the config file in /etc/my.cnf and change ALL the /tmp/mysql.socket lines to /var/run/mysqld/mysqld.sock or any other socket place you wish to send it. Note that the config file can also be in /etc/mysql/my.cnf in some cases like mine. The config file has at least 3 lines you need to change.







    share|improve this answer





















    • mysqld not running. /etc/init.d does not contain mysql file or folder.
      – BioDeveloper
      Apr 16 '14 at 5:50










    • There you go. Now copy the mysql server script found on the downloaded tar to the init folder and give it executable permissions. Then run it.
      – Luis Alvarado
      Apr 16 '14 at 14:17













    up vote
    0
    down vote










    up vote
    0
    down vote









    There are a couple of steps to check when you do it manually that could create the error mentioned above. I will assume you either manually downloaded MySQL from the official site or used a 3rd party PPA to install it:





    • Check that mysql is not already running:



      ps -e|grep -i 'mysqld'.



      If it appears then you need to kill it by doing a sudo killall -9 mysqld. In the case it does not die, then grab the PID from the ps you ran and kill -9 PID




    • Run mysql via /etc/init.d/mysql start to see if it creates the same error. If it gives you the exact same error from above then you need to copy the mysql.server file which is found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and you need to copy it to /etc/init.d/mysql eg:



      cp mysql.server /etc/init.d/mysql and give it a executable permission chmod +x then try running /etc/init.d/mysql start again.



    • If it still gives you a problem then you need to edit the config file in /etc/my.cnf and change ALL the /tmp/mysql.socket lines to /var/run/mysqld/mysqld.sock or any other socket place you wish to send it. Note that the config file can also be in /etc/mysql/my.cnf in some cases like mine. The config file has at least 3 lines you need to change.







    share|improve this answer












    There are a couple of steps to check when you do it manually that could create the error mentioned above. I will assume you either manually downloaded MySQL from the official site or used a 3rd party PPA to install it:





    • Check that mysql is not already running:



      ps -e|grep -i 'mysqld'.



      If it appears then you need to kill it by doing a sudo killall -9 mysqld. In the case it does not die, then grab the PID from the ps you ran and kill -9 PID




    • Run mysql via /etc/init.d/mysql start to see if it creates the same error. If it gives you the exact same error from above then you need to copy the mysql.server file which is found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and you need to copy it to /etc/init.d/mysql eg:



      cp mysql.server /etc/init.d/mysql and give it a executable permission chmod +x then try running /etc/init.d/mysql start again.



    • If it still gives you a problem then you need to edit the config file in /etc/my.cnf and change ALL the /tmp/mysql.socket lines to /var/run/mysqld/mysqld.sock or any other socket place you wish to send it. Note that the config file can also be in /etc/mysql/my.cnf in some cases like mine. The config file has at least 3 lines you need to change.








    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 15 '14 at 15:24









    Luis Alvarado

    143k135484649




    143k135484649












    • mysqld not running. /etc/init.d does not contain mysql file or folder.
      – BioDeveloper
      Apr 16 '14 at 5:50










    • There you go. Now copy the mysql server script found on the downloaded tar to the init folder and give it executable permissions. Then run it.
      – Luis Alvarado
      Apr 16 '14 at 14:17


















    • mysqld not running. /etc/init.d does not contain mysql file or folder.
      – BioDeveloper
      Apr 16 '14 at 5:50










    • There you go. Now copy the mysql server script found on the downloaded tar to the init folder and give it executable permissions. Then run it.
      – Luis Alvarado
      Apr 16 '14 at 14:17
















    mysqld not running. /etc/init.d does not contain mysql file or folder.
    – BioDeveloper
    Apr 16 '14 at 5:50




    mysqld not running. /etc/init.d does not contain mysql file or folder.
    – BioDeveloper
    Apr 16 '14 at 5:50












    There you go. Now copy the mysql server script found on the downloaded tar to the init folder and give it executable permissions. Then run it.
    – Luis Alvarado
    Apr 16 '14 at 14:17




    There you go. Now copy the mysql server script found on the downloaded tar to the init folder and give it executable permissions. Then run it.
    – Luis Alvarado
    Apr 16 '14 at 14:17










    up vote
    0
    down vote













    If your file my.cnf (usually in the /etc/mysql/folder) is correctly configured with



     socket=/var/lib/mysql/mysql.sock


    you can check if mysql is running with the following command:



     mysqladmin -u root -p status


    change your permission to mysql folder. If you are working locally, you can do:



     sudo chmod -R 755 /var/lib/mysql/





    share|improve this answer

























      up vote
      0
      down vote













      If your file my.cnf (usually in the /etc/mysql/folder) is correctly configured with



       socket=/var/lib/mysql/mysql.sock


      you can check if mysql is running with the following command:



       mysqladmin -u root -p status


      change your permission to mysql folder. If you are working locally, you can do:



       sudo chmod -R 755 /var/lib/mysql/





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        If your file my.cnf (usually in the /etc/mysql/folder) is correctly configured with



         socket=/var/lib/mysql/mysql.sock


        you can check if mysql is running with the following command:



         mysqladmin -u root -p status


        change your permission to mysql folder. If you are working locally, you can do:



         sudo chmod -R 755 /var/lib/mysql/





        share|improve this answer












        If your file my.cnf (usually in the /etc/mysql/folder) is correctly configured with



         socket=/var/lib/mysql/mysql.sock


        you can check if mysql is running with the following command:



         mysqladmin -u root -p status


        change your permission to mysql folder. If you are working locally, you can do:



         sudo chmod -R 755 /var/lib/mysql/






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 24 '16 at 4:37









        minigeek

        845412




        845412






























            draft saved

            draft discarded




















































            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.





            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%2faskubuntu.com%2fquestions%2f448094%2fcant-connect-to-local-mysql-server-through-socket-tmp-mysql-2-sock-during-ma%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

            Ellipse (mathématiques)

            Quarter-circle Tiles

            Mont Emei