/tmp/mysql.sock disappears after stopping mysql - can't restart on OSX - mysql

I am trying to get mysql set up properly on OSX Mavericks. I have installed the 3 packages from here http://dev.mysql.com/downloads/mysql/. Everything works as expected.
However, when I click Stop MySQL Server in the preferences pain window shown below, I cannot restart the server. I am pretty sure that this is due to the fact that the /tmp/mysql.sock file gets removed. The only way to get the server to start again is to restart my computer, which is less than ideal.
How can I get the /tmp/mysql.sock file to stick around even after stopping the server?
As a side note I have symlinked the mysql.sock file using this command, but I don't think this is related
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
I also noticed that I cannot find a my.cnf file anywhere. Should I create this file someplace?

I ended up removing all files using this post as a reference http://akrabat.com/computing/uninstalling-mysql-on-mac-os-x-leopard/ and reinstalling using homebrew brew install mysql. So far so good with this install. Probably was some kind of permission issue preventing mysql.sock from being created on start - but not too sure.

Related

Mysql server on MAMP won't start

My Mysql server on MAMP won't start.
This is the error:
161224 00:15:00 mysqld_safe Logging to '/Applications/MAMP/logs/mysql_error_log.err'.
161224 00:15:00 mysqld_safe Starting mysqld daemon with databases from /Applications/MAMP/db/mysql56
161224 00:15:01 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended
I already tried the following commands:
> ps aux | grep mysql
> lsof -i
> sudo killall -9 mysqld
But the server is still not working.
Help ?
Remove the files ib_logfileN (N being the number) from the MAMP/db/mysql56 folder.
Then restart MAMP.
Should Work!!
Edit: If the above step doesn't work completely, please remove the ibdata<n> file as well, based on the comments.
I am working on oS-X (Mac), I was wondering around and came to see this post which help me a lot.
Many readers are being able to solve this problem thanks to the amazing here are the step to fix it out--
This issue generally occur due to explicitly closing of MAMP serves.
Quit MAMP.
In the finder go to Applications/MAMP/db/mysql/
Delete the last log file (look for a file named ib_logfileN – being N the log number Eg-ib_logfile0 and ib_logfile1) we can see in below image.
Please back up these before you delete them.
Restart MAMP.
It Worked for me, hope will work for you too..
I killed the process mysqlid via Activity Monitor on MacOS and restarted MAMP and MySql run successfully.
Update: Even this solution works without restarting MAMP.
My MAMPs MySQL stopped working after a power failure, this worked for me:
Stop servers from terminal
cd /Applications/MAMP/bin
./stop.sh
Create my.cnf file in /Applications/MAMP/conf with the following:
[mysqld]
innodb_force_recovery = 1
Start MySQL from same terminal window.
./startMysql.sh
Stop MySQL once it has recovered (Check the log in /Applications/MAMP/logs/mysql_error_log.err).
./stopMysql.sh
Remove the lines from my.cnf, save and start the servers as usual from the MAMP app.
MAMP is so touchy. Here's what worked for me:
cd /Applications/MAMP
Move or rename: mv tmp tmp_OLD.
Recreate the folder and a subfolder:
mkdir tmp; mkdir tmp/mysql
Now start mysql from MAMP. I think it's possible the socket lock file (tmp/mysql/mysql.sock.lock) gets corrupted and needs to be regenerated.
In some cases it may possible that the MySQL is already running on 3306 port. So, you can change the port number with 3307.
P.S: If you are bound to use 3306 in that case I think you can stop existing MySql server and let MAMP to do it for you.
I tried everything but I don't know why I didn't find this solution yet.
Quit Mamp
Go To /Application/Mamp/tmp/mysql
Delete File mysql.sock.lock
Start Mamp Server and that's all
+1 if this answer is helpful :)

change mysql.sock path(not under /tmp/) in installation

I am new to building server, I need to install MySQL server on CentOS 5.10 (64-bit). I used source code for the installation as I cannot use the root account.
I have finished cmake, make, make install process, it goes fine, but when I tried to start the server, it said "can't connect to mysql server through socket ". I guess it's because I do not have /tmp/mysql.sock and I cannot find any mysql.sock created under my basedir.
Is there any way to create the mysql.sock under a desired directory? I do not have the access right to the /tmp/ dir, please help!
EDIT
When I cmake the files, I have added options to change data dir, tmp dir, mysql.sock, hoping to create the mysql.sock and the data dir under my desired path, like user/ws1/mysql/,however it seems that doesn't work, is there any way to do so?
After cmake, make, make install, you need to go to /usr/local/mysql/scripts and execute mysql_install_db -u root before starting MySQL. Hope this will help ~
You need to start the server before you connect to it with the mysql command.
To start it try running support-files/mysql.server start .

MySQL w/ MAMP - Symbolic link disappears after I quit MAMP

How can I change my MAMP mysql.sock file path from
/Applications/MAMP/tmp/mysql/mysql.sock
to something else that doesn't get deleted whenever I quit MAMP or restart the computer? I'm running Mac OS X Yosemite.
Details: MAMP / MySQL socket file gets erased every time I quit MAMP.
This is understandable, given that the mysql.sock file is stored in a tmp folder.
Current path is /Applications/MAMP/tmp/mysql/mysql.sock
Every time I run MAMP I have to recreate a symlink using the following command:
sudo ln -s [source] [target]
Source = /var/mysql/mysql.sock OR /tmp/mysql.sock
Target = /Applications/MAMP/tmp/mysql/mysql.sock
This is a known problem and a few answers have been given to other questions like this, but none provide a way to change where the MAMP mysql.sock file is stored.
I found that this has nothing to do with MAMP.
This file -> mysql.sock is not a definitive file, so to speak.
It's created every time you start mysqld, and it's deleted when you stop mysqld or restart/shutdown your computer.
So, to solve this you have to start mysqld every time you're going to do some database operation.
Or you can configure it as a startup program/script. Once you do this, your problems will be solved.

MySQL suddenly stopped LAMP stack

I have been using the LAMP stack on a Ubuntu setup.
It has been working fine, set up multiple databases everything is going fine, and then suddenly this morning I started getting database errors from the webpage I was using, then trying to access PHPMyAdmin got:
error #2002 Cannot log in to the MySQL server
I go into the bash prompt and try to log-in as the root user see whats up I get a similar error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
I checked that the mysql.sock file existed which it does, in the specified path in the error above. Permissions where all good, and owned by mysql. I reset the permissions just in case and still get the same error.
Here is the file as seen from BASH:
srwxrwxrwx 1 mysql mysql 0 Oct 21 05:10 mysqld.sock
I thought I would just restart the service, but get the same error when trying to stop, start or restart the service.
This really baffled me, I am no expert with linux or anything, but don't understand how this can suddenly happen when I didn't change any of the config settings, and it was running perfectly fine for the last few months.
I tried restarting Apache, and got the error:
apache2: bad user name ${APACHE_RUN_USER}
I don't think that is related to the MySQL stuff but thought it could be involved. The Apache error seems to more be with the set-up but knowing my luck being lazy has caused my to overlook simple things that has caused it all to come crashing down.
Any help on how to fix the problem, and more importantly prevent this occurrence the future would be greatly appreciated.
I have tried most things that were returned by a basic Google search, and a look around here. I have not yet tried deleting and recreating the sock file, but most other things so far have not worked.
EDIT:
I just wanted to add that the Apache server is still running fine, nothing wrong there even though I do get the error when trying to stop and restart it. Pages that don't rely on MySQL still load without issue.
I have also tried killing mysql processes through searching the PIDs and also as suggested below killall mysqld (and also killall mysql just for kicks). No processes found through these attempts.
I don't know if it is relevant or not, but I can't open (in vim) or view the mysqld.sock file (permission denied) even when using the superuser.
Have you tried using
killall mysqld
to kill the server instead of just ending the service, and then starting the MySQL service?
Or you could try deleting mysql.sock using
rm /var/run/mysqld/mysqld.sock
Then you would just need to run the MySQL server again by either starting the service or running
mysqld
It should create a new /var/run/mysqld/mysqld.sock for itself and all should go well.
Just a thought: this may have happened because the computer wasn't powered-off correctly, or perhaps MySQL just got a bit confused.
Create one micro instance swap space in Ubuntu
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
did you try to just restart the mysql server
/etc/init.d/mysqld restart
/etc/init.d/mysqld stop
/etc/init.d/mysqld start

Doctrine 2 command line tool; MAMP and mysql.sock

I grabbed the CI2/Doctrine2 from Wildly Inaccurate. I'm trying to start using it, but before I'm actually getting to work with it, I wanted to make sure everything works. However, when I try the command line tool, I run into the following error:
$ ./doctrine orm:schema-tool:create
ATTENTION: This operation should not be executed in a production environment.
Creating database schema...
Warning: PDO::__construct(): [2002] Socket operation on non-socket (trying to connect via unix:///var/mysql/mysql.sock) in /Users/joris/Desktop/ci2_starter/application/libraries/Doctrine/DBAL/Driver/PDOConnection.php on line 36
[PDOException]
SQLSTATE[HY000] [2002] Socket operation on non-socket
orm:schema-tool:create [--dump-sql]
I'm running this on a cleanly installed MAMP Pro 2.0.1; I'm not really sure what to do to fix this error.. I'm not really knowledgeable on the inner (background) workings of MySQL. Could someone clear this up for me? Thanks a lot.
Update:
MacBook-Pro-van-Joris-Ooms:~ joris$ sudo find / -name 'mysql.sock'
Password:
/Applications/MAMP/tmp/mysql/mysql.sock
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/private/var/mysql/mysql.sock
/private/var/mysql/mysql.sock/mysql.sock
MAMP does use it's own mysql socket while the CLi uses the default one in /var/mysql/mysql.sock.
This could mean you are running the wrong PHP version (not the MAMP one but the default MAC OS X one). Not a big deal since it can deal with your Doctrine Command Line Issues as well.
So you do have several options:
try using the MAMP php version to start the CLi tool by putting the Path to your MAC OS X php version as a prefix i.e.
/Applications/MAMP/bin/php5.3/bin/php ./doctrine orm:schema-tool:create
just set up a link from /var/mysql/mysql.sock to the actual Socket file which should be in /Applications/MAMP//tmp/mysql/mysql.sock
So you go to the terminal while your MAMP is running an type (You will be asked to type in a password):
sudo ln -s /Applications/MAMP//tmp/mysql/mysql.sock /var/mysql/mysql.sock
Find every occurrence of "/Applications/MAMP//tmp/mysql/mysql.sock" in any of your MAMP config files and change it to be /var/mysql/mysql.sock so you actually do use the default address for MySQL Socket. Though, i have never tested if this does work.