Mysql linux Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

Question:

mysql -u root -p

Enter password:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

Answer:

xianglongkong@Xianglong-Kongs-MacBook-Pro:~/Documents/mysite/db$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

Password:

Starting MySQL database server

xianglongkong@Xianglong-Kongs-MacBook-Pro:~/Documents/mysite/db$ mysql

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

xianglongkong@Xianglong-Kongs-MacBook-Pro:~/Documents/mysite/db$ cd /usr/local/mysql

xianglongkong@Xianglong-Kongs-MacBook-Pro:/usr/local/mysql$ ls

COPYING        README         data           include        man            scripts        sql-bench

INSTALL-BINARY bin            docs           lib            mysql-test     share          support-files

xianglongkong@Xianglong-Kongs-MacBook-Pro:/usr/local/mysql$ sudo ./bin/mysqld_safe

131118 17:48:46 mysqld_safe Logging to ‘/usr/local/mysql-5.1.65-osx10.6-x86_64/data/Xianglong-Kongs-MacBook-Pro.local.err’.

131118 17:48:46 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.1.65-osx10.6-x86_64/data

131118 17:48:46 mysqld_safe mysqld from pid file /usr/local/mysql-5.1.65-osx10.6-x86_64/data/Xianglong-Kongs-MacBook-Pro.local.pid ended

xianglongkong@Xianglong-Kongs-MacBook-Pro:/usr/local/mysql$ mysqld_safe

131118 17:49:33 mysqld_safe Logging to ‘/usr/local/mysql/data/Xianglong-Kongs-MacBook-Pro.local.err’.

131118 17:49:33 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

xianglongkong@Xianglong-Kongs-MacBook-Pro:~$ mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.65 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> exit

Bye

Question 2:

xianglongkong@Xianglong-Kongs-MacBook-Pro:~/Documents/mysite/db$ mysql -u root -p

Enter password:

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

xianglongkong@Xianglong-Kongs-MacBook-Pro:~/Documents/mysite/db$ /usr/local/mysql/bin/mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 449

Server version: 5.1.65 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> create database promos;

Query OK, 1 row affected (0.04 sec)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s