"Can't connect to local MySQL server"

Discussion in 'Server Operation' started by computerish, Jun 23, 2008.

  1. computerish

    computerish New Member

    I am trying to follow the Ubuntu LAMP for Newbies tutorial (http://www.howtoforge.com/ubuntu_lamp_for_newbies). I got to the step where you enter this command:
    Code:
    sudo apt-get install mysql-server
    It asked me to set a password, so I did. That was my mistake. (I do know what the password was.) When I then entered the next command:
    Code:
    mysql -u root
    I got the error that the password was wrong. I did not know how to enter my password into that command, so I went into Synaptic and marked mysql-server for complete removal then went back to the command line and reinstalled mysql-server.
    That worked, but it did not ask me for a password. Now when I try mysql -u root, I get this:
    Code:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    Now what do I do?

    Thanks so much!
     
  2. topdog

    topdog Active Member HowtoForge Supporter

    make sure the server is running
     
  3. computerish

    computerish New Member

    Thanks! Just before I saw your response I was looking around the web and tried starting the server, but I am glad for confirmation that I did the right thing. Anyway, it worked - sort of. Now I get a different error, though.
    Code:
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    I know what the password is, but I don't know what syntax I would use to put the password into the command (mysql -u root).

    Thanks very much!
     
  4. computerish

    computerish New Member

    Nevermind. Thanks! I figured it out.

    For anyone else with the same problem. The code to start the server is:
    Code:
    sudo /etc/init.d/mysql start
    And I changed this command:
    Code:
    mysql -u root
    Into this command to get it to ask for a password
    Code:
    mysql -u root -p
    Thanks very much!
     

Share This Page