So I checked /usr/local/etc/rc.d/mysql-server and it said to add the following:

Code:

# Add the following line to /etc/rc.conf to enable mysql:
# mysql_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable MySQL.
# mysql_limits (bool): Set to "NO" by default.
# Set it to yes to run `limits -e -U mysql`
# just before mysql starts.
# mysql_dbdir (str): Default to "/var/db/mysql"
# Base database directory.
# mysql_args (str): Custom additional arguments to be passed
# to mysqld_safe (default empty).

Then I tried to start mysql with "sudo /usr/local/etc/rc.d/mysql-server start"

All I saw was "Starting mysql.", then nothing happened. I tried to query the server with "mysqladmin ping" and the response was

Code:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

I'm not sure what to do next. Any suggestions would be much appreciated - is there a way to get verbose output from "mysql-server start"?

If this is a fresh install, you may also have to initialise the internal database and tables. The rc.d script is supposed to do this automatically, but sometimes it doesn't. Try running the following:#/usr/local/bin/mysql_install_db
And then running the rc.d script.

If that doesn't work, check /var/log/messages and the mysql logs in /var/db/mysql.

If this is a fresh install, you may also have to initialise the internal database and tables. The rc.d script is supposed to do this automatically, but sometimes it doesn't. Try running the following:#/usr/local/bin/mysql_install_db
And then running the rc.d script.

If that doesn't work, check /var/log/messages and the mysql logs in /var/db/mysql.

I ran the mysql_install_db command, and it ran without incident. I then tried to start mysql and it did nothing in particular. "mysqladmin ping" still returns the error

Code:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

/var/log/messages is useless for mysql, at least this installation of it. /var/db/mysql has a log file that appears almost hopeless.

Would it be at all useful to try uninstalling and reinstalling through ports, or do I have to muck through this by hand? It seems like there could be multiple missing things that are important to mysql, as the following lines from the /var/db/mysql log file indicate:

If this is a fresh install, you may also have to initialise the internal database and tables. The rc.d script is supposed to do this automatically, but sometimes it doesn't. Try running the following:#/usr/local/bin/mysql_install_db
And then running the rc.d script.

If that doesn't work, check /var/log/messages and the mysql logs in /var/db/mysql.

Dear Sir phoenix,
Mine is the same problem except mine's not fresh install.

"mysqladmin ping" shows the same message as mantazz i.e.

Quote:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

If this is a fresh install, you may also have to initialise the internal database and tables. The rc.d script is supposed to do this automatically, but sometimes it doesn't. Try running the following:#/usr/local/bin/mysql_install_db
And then running the rc.d script.

If that doesn't work, check /var/log/messages and the mysql logs in /var/db/mysql.

You should run:#mysql_install_db --user=mysql

Otherwise the ownership for the MySQL database are set to root:wheel, and since mysqld_safe is run as the mysql user ...

If you've already run mysql_install_db, then just remove the /var/db/mysql directory and re-run the command with the --user argument (Assuming, ofcourse, there is nothing of value in /var/db/mysql).

__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.