Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: "Can't connect to local MySQL server through socket"

  1. #1
    Join Date
    May 2008
    Beans
    39

    "Can't connect to local MySQL server through socket"

    I'm setting up a mail server with 7.10, following the directions on this website: http://flurdy.com/docs/postfix/#install. I'm at the part where you create the mysql database. So when I put in the command
    Code:
    mysqladmin -u root password new_password
    it tells me this:
    Code:
    mysqladmin: connect to server at 'localhost' failed
    error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
    Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
    How do I create the mysqld.sock?

  2. #2
    Join Date
    Mar 2008
    Beans
    4,714
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: "Can't connect to local MySQL server through socket"

    First check that mysqld is installed:
    Code:
    which mysqld
    This should return
    Code:
    /usr/sbin/mysqld
    Next check that mysqld is running:
    Code:
    pgrep mysqld
    This should return a line(s) with a number(s). This in the process id number (PID).
    If you don't see any number, then check that mysql is set to start when you boot up:
    Code:
    ls /etc/rc2.d | grep mysql
    You should see
    Code:
    S17mysql-ndb-mgm
    S18mysql-ndb
    S19mysql
    If you see this, reboot, and mysqld should run and /var/run/mysqld/mysqld.sock should be created for at boot time.

    If you don't see the output described above, then post the commands and their output and we'll go from there.
    Last edited by unutbu; November 8th, 2008 at 09:15 PM.

  3. #3
    Join Date
    May 2008
    Beans
    39

    Re: "Can't connect to local MySQL server through socket"

    I had to reboot. So now when I enter
    Code:
    pgrep mysqld
    it returns with
    Code:
    6406
    6446
    So after that I tried
    Code:
    mysqladmin -u root password new_password
    again. Now it tells me
    Code:
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: NO)'
    I'm already in root. So I don't think that's the case.

  4. #4
    Join Date
    Mar 2006
    Location
    Williams Lake
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: "Can't connect to local MySQL server through socket"

    when start mysql you have to use the password you set when you installed it.

    Code:
    mysql -u root -p
    should result in this after you enter your password:

    Code:
     mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 407
    Server version: 5.0.67-0ubuntu6 (Ubuntu)
    
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    
    mysql>
    Jim

  5. #5
    Join Date
    May 2008
    Beans
    39

    Re: "Can't connect to local MySQL server through socket"

    Code:
    root@server:/home/kami# mysql -u root -p
    Enter password:
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    I've tried everything that I used. Is there a way to reset it all?

    And just to make sure I'm doing this right, the code is
    Code:
    mysqladmin -u root password password_i_choose
    Correct?

  6. #6
    Join Date
    Mar 2008
    Beans
    4,714
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: "Can't connect to local MySQL server through socket"

    kami_iwinaru, what happens when you type
    Code:
    mysql -u root
    If you get a mysql> prompt, then type
    Code:
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
    Change yourpassword to whatever you wish.
    Keep the single quotes, they are part of the command.

    If, on the other hand, the above command does not get you to a mysql> prompt, then do this:

    Code:
    sudo /etc/init.d/mysql stop
    sudo mysqld --skip-grant-tables &
    mysql -u root
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION; 
    mysql>flush privileges
    mysql>quit
    sudo killall mysqld
    sudo /etc/init.d/mysql start
    This will allow you to (re)set your mysql root password. You can also skip to
    Code:
    mysqladmin -u root password password_i_choose
    command. If you'd like to check that mysqladmin works, however, do this:

    Code:
    mysqladmin -u root -p version
    You should see some innocuous version info.

    When prompted for a password, type in your mysql root password.

    Note that once a mysql root password has been set,
    you must always use the -p flag when using the mysql or mysqladmin commands. The -p flag tells the program to prompt for a password.

    Your mysql root password is a completely different thing than your Ubuntu password(s). For security's sake, they should be different passwords.
    Last edited by unutbu; November 9th, 2008 at 04:02 AM. Reason: added a missing &

  7. #7
    Join Date
    May 2008
    Beans
    39

    Re: "Can't connect to local MySQL server through socket"

    The "mysql -u root" command didn't work the first time. So I did the
    Code:
    sudo /etc/init.d/mysql stop
    That stopped fine, but when I entered
    Code:
    sudo mysqld --skip-grant-tables
    it comes up with
    Code:
    081108 21:51:16  InnoDB: Started; log sequence number 0 43655
    081108 21:51:17 [Note] mysqld: ready for connections.
    Version: '5.0.45-Debian_1ubuntu3-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Debian etch distribution
    and after that, it just stops. Doesn't do anything. I left it there for a good 10 minutes and still nothing. So that's where I'm stuck.

  8. #8
    Join Date
    Mar 2008
    Beans
    4,714
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: "Can't connect to local MySQL server through socket"

    Sorry, I forget to put a & after the command.
    Code:
    sudo mysqld --skip-grant-tables &

  9. #9
    Join Date
    May 2008
    Beans
    39

    Re: "Can't connect to local MySQL server through socket"

    Still did the same thing. Someone told me to use phpMyAdmin. But I tried it, and it's confusing the hell out of me, so I think I'd rather do this.

  10. #10
    Join Date
    Mar 2008
    Beans
    4,714
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: "Can't connect to local MySQL server through socket"

    Type
    Code:
    sudo mysqld --skip-grant-tables &
    Then press return. You should get a prompt back.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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