LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   mysql error connect to server at 'localhost' failed (http://www.linuxquestions.org/questions/linux-server-73/mysql-error-connect-to-server-at-localhost-failed-525597/)

pete44904 02-04-2007 05:16 PM

mysql error connect to server at 'localhost' failed
 
Hi i am currently trying to get mysql installed so that i can try out XOOPS on my Fedora 6 test box - but when i try to use the command
Quote:

mysqladmin -u mysql -p create xoops4
to create a new user it asks me for a password for mysql but i haven't given it one yet and when i enter a password i get the following error. I have tried to search google for a solution to it but i couldn't find one.:)

Code:

[root@xoops ~]# mysqladmin -u mysql -p create xoops4
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'mysql'@'localhost' (using password: YES)'

Any help on what i am doing wrong would be greatly appreciated -

kdrlx 02-04-2007 08:44 PM

have you set the password for the mysql-root account ? if not first do that -
$> mysqladmin -u root password 'new-password'

check if you can connect with the root account -
$> mysql -u root -p
It will prompt for password. Enter the one you just created.

.. then add users and then create databases etc.

dhana_space1 07-26-2007 02:47 AM

same problem...
 
[~]# mysqladmin -u root -p status
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

any solution or any help ?

Sanford Stein 06-30-2009 12:06 PM

Was a solution to this ever found?

I installed MySql, and I get the failure to connect to localhost running mysql or mysqladmin no matter what user I try. It is not possible to set a password for a user because of the failure to connect.

Thanks,
Sanford Stein

elfoozo 06-30-2009 01:21 PM

Have you seen this thread? Few good suggestions to try.

http://forums.mysql.com/read.php?35,64808,64808

Sanford Stein 06-30-2009 03:08 PM

Actually I found the solution at:

http://www.redhat.com/magazine/007may05/features/mysql/

The command that worked was:

# mysql -u root -p -h localhost

and then I entered my root password at the prompt and got mysql>

Why this worked, and nothing else did, I can't say

Wim Sturkenboom 07-01-2009 12:25 AM

@Sanford Stein

The mysql client makes certain assumptions when you don't pass information on the command line. In this case it might have passed the wrong host to the server.

PS You did not post the exact error that you got, but I think it was a different one from the one in the opening post.

fear_matrix 09-05-2010 05:16 AM

This issue arrises because there is no sqladmin install. Please install the sqladmin by issuing the below command

yum install mysql-server

sukujgrg 09-05-2010 09:31 AM

The correct syntax for passing password with "mysql" command is as follows.

[suku@techtrunch]mysql -u root -pyourpassword -h localhost ###see no space after "-p".

If you have forgotten the password, since you have root account, reset it. There are lot of sites describing about resetting mysql user passwords. Simply follow those.

----
Suku
techtrunch.com

fear_matrix 09-10-2010 01:54 PM

Just wanted to make one more point here, sometimes you will get the below error when you restart your linux server

Code:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
So in order to solve this problem you need to restart your mysqld by using the below command

Code:

service mysqld restart

TheIndependentAquarius 11-23-2012 06:08 AM

Following steps solved this error for me.

openSUSE 11.4
Server version: 5.1.53
Code:

sudo /usr/bin/mysql_install_db
sudo /etc/init.d/mysql start
sudo mysqladmin -u root password 'new'
mysql -h localhost -u root -pnew



All times are GMT -5. The time now is 04:40 PM.