Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql.sock

Status
Not open for further replies.

Aphotic

Technical User
Joined
Feb 23, 2007
Messages
6
Location
US
I installed mysql through ports on freebsd 6.1. i started the daemon, and mysql starts. however when i try "mysql" i get

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

i looked this up on the mysql page and did find much help. first i tried

shell> chmod +t /tmp

to protect tmp. that didnt solve it, so i tried to point my sock file to another directory in /etc/my.cnf:

[mysqld]
socket=/usr/local/etc

[client]
socket=/usr/local/etc

i got the same error message:

# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/etc' (38)
#

even with the new directory.

i tried mysqld_safe:

# mysqld_safe
Starting mysqld daemon with databases from /var/db/mysql
rm: /usr/local/etc: is a directory
STOPPING server from pid file /var/db/mysql/hostname.com.pid
070312 10:39:46 mysqld ended

does anyone know where my problem lies? thanks!
 
First thing to check on is the permission of the /var/db/mysql directory. The user/group should be something like "mysql:mysql". Finally, you should use an init script to start MySQL like the one provided below.
Code:
#!/bin/sh

pid_file=your.hostname.pid

bin_dir=/usr/local/bin
etc_dir=/usr/local/etc

db_dir=/var/db

case "$1" in
start)
	[ -x $bin_dir/mysqld_safe ] &&
	$bin_dir/mysqld_safe --defaults-extra-file=$etc_dir/my.cnf --user=mysql --datadir=$db_dir/mysql --pid-file=$db_dir/mysql/$pid_file [b]--skip-networking[/b] & > /dev/null &&
	echo -n "MySQL started" &&
	echo
	;;
stop)
	[ -r $db_dir/mysql/$pid_file ] &&
	mysqld_pid=`cat $db_dir/mysql/$pid_file` &&
	echo "Killing mysqld with pid $mysqld_pid" &&
	kill $mysqld_pid &&
	sleep 1
	;;
restart)
	$0 stop
	$0 start
	;;
*)

echo "Usage: `basename $0` {start|stop|restart}" >&2
;;

esac

exit 0

NOTE: Remove this unless you plan to run the MySQL server locally.

M. Brooks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top