简体   繁体   中英

MAMP : Mysql won't turn on

My mamp mysql server won't turn on. I tried executing /Applications/MAMP/bin/startMysql.sh but that gave me this error :

101110 05:50:31 mysqld_safe Logging to '/Applications/MAMP/logs/mysql_error_log.err'.

101110 05:50:32 mysqld_safe Starting mysqld daemon with databases from /Applications/MAMP/db/mysql

101110 05:50:32 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended

/Applications/MAMP/logs/mysql_error_log.err :

InnoDB: http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html

InnoDB: Could not open or create data files.

InnoDB: If you tried to add new data files, and it failed here,

InnoDB: you should now edit innodb_data_file_path in my.cnf back

InnoDB: to what it was, and remove the new ibdata files InnoDB created

InnoDB: in this failed attempt. InnoDB only wrote those files full of

InnoDB: zeros, but did not yet use them in any way. But be careful: do not

InnoDB: remove old data files which contain your precious data!

101110 5:53:08 [ERROR] Plugin 'InnoDB' init function returned error.

101110 5:53:08 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

101110 5:53:08 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use

101110 5:53:08 [ERROR] Do you already have another mysqld server running on port: 3306 ?

101110 5:53:08 [ERROR] Aborting

101110 5:53:08 [Warning] Forcing shutdown of 2 plugins

101110 5:53:08 [Note] /Applications/MAMP/Library/libexec/mysqld: Shutdown complete

101110 05:53:08 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended

twob.net has a pretty good fix for it. Go Into terminal and type in

killall -9 mysqld 

Check it - http://twob.net/journal/fix-for-mamp-mysql/ . Worked for me

What I have found is that at times more than one occurrence of mysql is running. What I do when MySQL will not start is I first quit MAMP, then I go into the Applications/utlities and open the Activity Monitor. From there I search for "my" which should bring up any mysql's that may be running. I then either quit or force quit mysql. At that point I'm able to open MAMP with a working MySQL server.

Hope that helps.

This command worked for me.

     ps aux | grep mysql 
     lsof -i 
     killall -9 mysqld

if needed

    sudo killall -9 mysqld

Ref: http://www.witheringtree.com/2010/05/how-to-resolve-mysql-not-starting-in-mamp/

With a new/clean install of MAMP 4.1.1, I had the same problem.

When running: /Applications/MAMP/bin/startMysql.sh

MySql reported:

mysqld_safe error: log-error set to '/Applications/MAMP/logs/mysql_error_log.err', however file don't exists. Create writable for user 'mysql'. .

So, I ran touch /Applications/MAMP/logs/mysql_error_log.err and tried again with startMysql.sh . It worked (but it wasn't quite "by itself")!

Well I'm glad for you it fixed itself on its own ;)

From the look of your error file, it looks like you already had an instance of MySQL running... Not sure if this works on a mac, but you could try :

pidof mysqld

If this outputs something (one or several numbers), then MySQL is running. If the output is empty, then it is not.

There are multiple ways to fix this - usually one works.

To start off, try quitting MAMP and then:

sudo killall -9 mysqld

If that fails, try going to Preferences > Ports and changing to MAMP default. Click 'OK'. MySQL should then start. If your website doesn't show up at localhost , try changing the ports back.

You can also stop MAMP, go to System Preferences > MySQL and turn off MySQL and then restart MAMP.

Hope this helps!

other way that might fix the same problem :

-go in the folder MAMP/db/mysql/ – delete all files that IS NOT A FOLDER (files like 'mysql-bin.XXXXXX' / 'mysql-bin.index'/ 'ibdata1' / 'ib_logfileX'

don't worry, this doesn't erase any of your database, but make sure you don't delete the folders. That's where the data of your databases are stored.

Another gotcha:
Check who is the owner of /Applications/MAMP/logs/mysql_error_log.err

On my machine, it is owned by admin: admin .
/Applications/MAMP/bin/startMysql.sh will fail to start, even if run with sudo.

But this will work:

sudo su admin
/Applications/MAMP/bin/startMysql.sh

There's another reason why this could be happening and I don't see anyone mentioning it, so I'll explain it in this answer.

When you reboot your computer, sometimes you force-close the apps and MAMP is not able to shutdown MySQL properly which leaves the socket file intact instead of MySQL removing it cleanly as part of its shutdown process. From what I understand (sources needed), MySQL used to make a socket file verification if it was forced to shutdown before, but it's not doing it anymore. Here's what you need to do:

  1. Make sure no MySQL instance is still running by typing killall -9 mysqld in terminal, then press enter to execute the command. It will shut down all the leftover mysql instances running.
  2. Go to /Applications/MAMP/tmp/mysql
  3. Find the mysql.sock file and delete it. It could be named mysql.sock.lock as well.
  4. Restart MAMP.

Everything should be booting up and running fine now. If not or if you can't find the mysql.sock file, your issue could be another one mentioned in the other answers.

Jmeyer, on occasion MAMP will do strange things like refuse to restart. When this happens, go to the MAMP application and click "preferences" and then just click "Ok."

For some reason this forces a restart of the MAMP server.

Not sure if that's what you were looking for, but a helpful tip nonetheless.

This is what did it for me, in terminal:

sudo chown -R mysql:mysql /usr/local/mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM