[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 661
  • Last Modified:

Change Default Mysql Port

When I try to login to mysql on my server via console, I get:

$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysqld/mysqld.sock' (38)

It's trying to go to the wrong socket.  Via phpmyadmin, I know it's working correctly at a different socket location: /tmp/mysqld/mysqld.sock  (for instance)

How do I change the default socket location from console, so it always points to the correct location?
1 Solution
edit the file /etc/my.cnf

the socket is listed in over there and change it to the location that you know is correct
mysql -u root -p -S /path/to/your/socket

man mysql and mysql --help are good friends to have.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now