PDA

View Full Version : "Can't connect to local MySQL server"


computerish
23rd June 2008, 22:42
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:
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:
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:
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!

topdog
24th June 2008, 11:29
make sure the server is running

computerish
24th June 2008, 15:13
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.
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!

computerish
24th June 2008, 15:40
Nevermind. Thanks! I figured it out.

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

Thanks very much!