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.
Related
I have a LAMP stack setup. Occasionally, I get the following error message when I open some page from the browser:
Error creating the connection!: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I think the server was configured correctly. The problem happens about every two months. Every time when I reboot the Linux server, or restart mysql, the problem was gone. I want to fix this problem permanently. Can anyone give me some idea?
Much appreciated.
EDIT
The problem occurs again and I checked the mysqld.sock file, it was not there. Do you have any idea how to fix the problem? – Ryan Jul 23 at 16:24
If your file my.cnf (usually in the /etc/mysql/ folder) is correctly configured with
socket=/var/run/mysqld/mysqld.sock
modified
#bind-address = 127.0.0.1
to
bind-address = localhost
you can check if mysql is running with the following command:
mysqladmin -u root -p status
try changing your permission to mysql folder. If you are working locally, you can try:
sudo chmod -R 755 /var/run/mysqld/
And then restart the mysql.
Good luck.
Could it be the log file getting too large and rebooting flushes it. See this in docs on server maintenance and logfiles. Also see discussion at digital ocean. Appears to be confirmed by discussion at serverfault
You could try change the permission of your MySQL sock file like this:
chmod 777 '/var/run/mysqld/mysqld.sock'
It is a test to see if whatever user mysqld is using, it will acess your mysqld.sock file. So, reboot your MySQL and change the permission of mysqld.sock. And you need to check that if your sock folder can be accessed through any mysqld process.
If the mysqld.sock file doesn't exist, that is to say your config file is not correct.Check your mysql config file in /etc/mysql/my.conf, find the socket config just as Vanya Avchyan says.
I think the socket config is /var/run/mysqld/mysqld.sock, but in fact your mysql process runs in other place sock file.
I used to met that problem, the real socket file exists in /tmp/mysqld.sock.
So run
sudo find / -name 'mysqld.sock'
to find the real sock file and change my.conf to this real place, restart your mysql. May have work.
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 :)
I managed to download the MySQL DMG archive to my OS (mac OS X). It works if I use the command line.
Now, I'm trying to install MySQL Workbench.
I've created MySQL Connection but once I'm testing the host machine settings, I get:
Checking command 'ps xa | grep "/usr/local/mysql.*/bin/[m]ysqld"'
Server detected as running
Check if /etc/my.cnf can be accessed
Operation failed: File /etc/my.cnf doesn't exist
I'm trying to find the file my.cnf and I get:
Didis-MacBook:~ Didi$ find . -type f -name "*my.cnf*"
find: ./perms/newdir: Permission denied
So I tried to create my own "my.cnf" by entering:
cd /usr/local/mysql/support-files/
sudo cp my-huge.cnf /etc/my.cnf
Then it asked for a password. I don't remember setting up a password.
So I typed:
/usr/local/psa/bin/admin --show-password
and get:
-bash: /usr/local/psa/bin/admin: No such file or directory.
I believe my password should be in /etc/passwd but I have no dir "etc" in my system!
I'm running out of ideas, can somebody help me please?
I figured it out:
Went to my terminal and typed:
passwd
Old password was blank
I created a new password (it was THAT simple)
I created a "etc" directory
I checked the files under /usr/local/mysql/support-files/ and saw my cnf file was actually named my-default.cnf and not my-huge.cnf like the developer at the MySQL site.
So I typed: sudo cp my-default.cnf /etc/my.cnf
went back to the Workbench and it FINALLY said:
Testing host machine settings is done.
The MySQL Server installation on OS X does not include a cnf file, so it is normal that you get the warning. Nonetheless you can continue creating the connection without problems (ignore the warning). When you start MySQL Workbench afterwards and try to manage the configuration of the server, you will get another warning, but you can continue and MySQL Workbench creates the cnf file for you. No need to do all that manually.
I met this problem too. I just clicked the continue button until i was at "Review remote management settings" step, and stop here click "change parameters", then continue. At "Path to configuration file" choose the path point to my-default.cnf. Then check path, it works
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.
I run ubuntu 12.04.
I am trying to move the temp dir for files as /tmp has filled up, somehow I only set it to 1meg, which is obviously not enough for a large mysql database.
What I need to do is move it on, so I looked online for a solution to this and I found an article which seems to make sense.
In the my.conf file at /etc/mysql/my.conf I changed the tmpdir directive to /mysqltmp. I made the directory with root login, then chmod 777 that dir. I reboot and the mysql server wont start. (it was starting just previously).
The error log says..
/usr/sbin/mysqld: Can't create/write to file '/mysqltmp/ibqADloJ'
It's a permissions error, however the directory has full permissions so why is this a problem?
Probably apparmor is getting in your way. Have a look at /etc/apparmor.d/usr.sbin.mysqld and make your new temp-folder writable by the mysqld process (or configure mysqld to write its temporary data to a directory it has write permissions for)