FedoraForum.org - Fedora Support Forums and Community
Results 1 to 9 of 9
  1. #1
    Shark Guest

    Solving MySQL ERROR 2002

    Hello guys, this is how I got MySQL-4.0.20 (source distribution) working, I've been stuck with the '2002 ERROR' complaining about the 'mysql.sock'

    Code:
    ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    First, I copy a configuration file, in somewhere like 'support files', choose 'my-medium.cnf' or 'my-large.cnf' .... and paste it in /etc/my.cnf, yes change the name to 'my.cnf'.

    In that file you can change the path to the socket file, 'Socket = /path/to/socket'.
    Another thing I did is make a empty 'mysql.sock' file and place it in the 'path/to/socket(you can also copy it somewhere from the installation package).

    And before to launch the
    Code:
    /usr/local/mysql/bin/mysql
    I did
    Code:
    /usr/local/mysql/bin/mysqld_safe &
    so : my.cnf, the sock file 'mysql.sock', and 'mysqld_safe' ...
    Hope this will help.
    Last edited by Shark; 19th July 2004 at 04:21 PM.

  2. #2
    alex3 Guest
    Quote Originally Posted by Shark
    Hello guys, this is how I got MySQL-4.0.20 (source distribution) working, I've been stuck with the '2002 ERROR' complaining about the 'mysql.sock'

    Code:
    ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    First, I copy a configuration file, in somewhere like 'support files', choose 'my-medium.cnf' or 'my-large.cnf' .... and paste it in /etc/my.cnf, yes change the name to 'my.cnf'.

    In that file you can change the path to the socket file, 'Socket = /path/to/socket'.
    Another thing I did is make a empty 'mysql.sock' file and place it in the 'path/to/socket(you can also copy it somewhere from the installation package).

    And before to launch the
    Code:
    /usr/local/mysql/bin/mysql
    I did
    Code:
    /usr/local/mysql/bin/mysqld_safe &
    so : my.cnf, the sock file 'mysql.sock', and 'mysqld_safe' ...
    Hope this will help.

    Hi,

    I have the same problems. From where do you copy the confiuraion file?

    Thanks,



    from where

  3. #3
    DRE.ORGY.NET Guest
    Its a permission problem. The user your trying access /var/lib/mysql/mysql.sock as doesnt have permission to that folder. You should be running mysqld as another user and this user should have full access to /var/lib/mysql/*

  4. #4
    oxman Guest
    That doesn't make sense to me. i have tried to start MySQL as a user and as root to no avail. Could you please be more specific on how to remove this error? I have done a thurough search for the mysql.sock file and it does not exist on my system hense the error. The server does not start at bootup and any attempt to start mysql from the CLI fails with this error:

    Starting MySQLCouldn't find MySQL manager or server

    When I do > mysqladmin -u root ping

    mysqladmin: connect to server at 'localhost' failed
    error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
    Last edited by oxman; 28th November 2005 at 04:55 PM. Reason: new information

  5. #5
    DRE.ORGY.NET Guest
    I am pretty sure that if you run the init.d script ( /etc/init.d/mysql or /etc/init.d/mysqld depending how you installed it) it will change to the mysql user regardless.

    How to fix it chown -R mysql:mysql /var/lib/mysql (replace mysql:mysql with appropiate user and group). If you want to check this before you do it try doing an ls -la /var/lib

    This is my output for the mysql directory
    drwxr-x--- 5 mysql mysql 4096 Nov 29 18:33 mysql

    if your output is like the one below its because only root can write to that directory.
    drwxr-x--- 5 root root 4096 Nov 29 18:33 mysql

    I had the exact same problem and what I did was what I mentioned above and it worked like a charm.

    Note: Also you might need to add other users to the mysql group if you are going to use mysql administrator as it will need direct access to the mysql.socks file too.

  6. #6
    oxman Guest
    I haven't tried this yet so YMV.
    I did ls -al on /var/lib/. The result was that /var/lib/mysql was owned by 27. That correct. The user was number 27 and should have been mysql. Here is a reply I received from the L4C (Linux for Christians) list I am on.
    Make sure that if everything is coming up as owned by '27' that when you create the mysql user, you make his user ID 27, homedirectory wherever mysql is, and the shell /bin/false:
    Eg.
    useradd -u 27 -s /bin/false -d /var/lib/mysql -G mysql mysql
    Also note that -G for primary group. I'm using Gentoo and portage creates a mysql group. I don't know what the situation is for FC.
    You won't need to change ownership of anything then, because it will suddenly "magically" translate the '27' into 'mysql' and be able to run.
    The mysql package was not creating a mysql user

  7. #7
    wroscoe Guest
    I had this same error and apparently it was because mysql was not started. I followed the instructions listed here http://www.thescripts.com/forum/post266499-2.html and copied below and its working great now.

    chkconfig --level 35 mysqld on
    /etc/init.d/mysqld start

  8. #8
    Join Date
    Jul 2013
    Location
    Finland
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Solving MySQL ERROR 2002

    I've been trying to resolve this #2002 mysql error too. Those instructions has helped me! Wanted to share with you

  9. #9
    Join Date
    Aug 2009
    Posts
    11,390
    Mentioned
    98 Post(s)
    Tagged
    0 Thread(s)

    Re: Solving MySQL ERROR 2002

    Hmmm.. Original post was over 9 years ago.. last post was over 5 years ago.. I say this was a dead post you resurrected

    Closing it up for good this time

Similar Threads

  1. Replies: 6
    Last Post: 1st December 2011, 11:44 AM
  2. Mysql 2002
    By DubiousBM in forum Servers & Networking
    Replies: 5
    Last Post: 31st December 2007, 10:21 PM
  3. MySQL-server-4.1.10a-0 ERROR 2002 (HY000) Start up problem
    By DoorGunner in forum Servers & Networking
    Replies: 3
    Last Post: 7th April 2005, 07:13 PM
  4. MySQL 2002 error
    By fragpot in forum Using Fedora
    Replies: 0
    Last Post: 27th October 2004, 05:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •