karikari
karikari

Reputation: 6797

want to change password for mysql root, but got error

I install Mysql5 using macports. But when trying to create password for the root account, I got this error:

sh-3.2# /opt/local/lib/mysql5/bin/mysqladmin  -u root password 123456
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (61)'
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!

How to fix this?

Upvotes: 0

Views: 1620

Answers (2)

Philoxopher
Philoxopher

Reputation: 1674

Check to see if the mysql daemon is running

ps aux | grep mysqld

If it is you should see something like:

mysql    28290  1.1  2.7 340496 56812 ?        Sl   Jul31 348:27 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock

If you are lucky you will see the --socket argument specifying exactly where your socket file is located. If it is somewhere different than the path your mysql client is looking for (/opt/local/var/run/mysql5/mysqld.sock), then you can specify it manually as one of the command line arguments.

Also, you should check to see if /etc/my.cnf exists and is setup properly, here is an example my.cnf:

[mysqld]
user=mysql_owner
datadir=/path/to/datadir/mysql
socket=/path/to/datadir/mysql/mysql.sock
skip-innodb

[mysql.server]
user=mysql_owner
basedir=/path/to/datadir

[client]
user=mysql_owner
socket=/path/to/datadir/mysql/mysql.sock

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Hope this helps, fire away with questions if you are still having issues

Upvotes: 1

vbence
vbence

Reputation: 20333

Check what is the default socket for your distribution. You can also try connectiong on TCP4 using:

/opt/local/lib/mysql5/bin/mysqladmin -h 127.0.0.1 -u root -p secret

Or if you have found the path to your socket (in mysql's config file) you can use somthing like:

/opt/local/lib/mysql5/bin/mysqladmin --socket=/tmp/mysql.sock -u root -p secret

Upvotes: 0

Related Questions