After MySQL install via Brew, I get the error - Th

2019-01-12 16:55发布

Ok, I've searched all over and have spent quite a bit of my time installing, uninstalling, trying various option but without success.

I'm on Mac OS X Lion (10.7.3) and am trying to setup a Python, MySQL.

I successfully installed Python and MySQL via HomeBrew. Python works great.

After MySQL Installation, I followed the first 2 steps - unset and the mysql_install_db commands.

Now, when I try to start mysql "mysql.server start", I get the following error

ERROR! The server quit without updating PID file (/usr/local/var/mysql/Brajeshwar.local.pid).
  • Brajeshwar is my username on my machine.

25条回答
Juvenile、少年°
2楼-- · 2019-01-12 17:26

This is file permission problem. Check disk permissions and repair.

Osx => Cmd+Space => Disk Utilty => Verify Disk Permissions.

Verify completed after Repair Disk Permissions. mysql.server start command is worked succesfuly.

查看更多
女痞
3楼-- · 2019-01-12 17:27

None of the answers worked for me. However, I simply did sudo mysql.server start and it worked nicely.

Also, for me, it did NOT show permissions issue in *.err file.

查看更多
Animai°情兽
4楼-- · 2019-01-12 17:28

November, 2014: If you're getting this error on MySQL 5.6.x on Mac OS X Mavericks or Yosemite and want to use MySQL with PHP locally (/tmp/mysql.sock is where PHP PDO expects to find the sock file), here is what fixed it for me:

1) Uncomment the default homebrew config file lines and edit as below

$ sudo vi /usr/local/Cellar/mysql/5.6.21/my.cnf
...
basedir = /usr/local/Cellar/mysql/5.6.21
datadir = /usr/local/var/mysql
port = 3306
server_id = <UNIQUE_NUMBER_HERE_OR_LEAVE_COMMENTED_OUT>
socket = /tmp/mysql.sock
pid-file = /usr/local/var/mysql/[BOXNAME].local.pid
....

BOXNAME is what you have in your System Prefs -> Network as the unique id for your computer on the network.

2) Set permissions on all the files in the mysql datadir. These were all owned by [my_username]. MySQL is very picky about this and refuses to create the pid file unless it (the user _mysql) owns the directory.

$ sudo chown -R _mysql:mysql /usr/local/var/mysql

3) Start MySQL using the bash helper/wrapper script:

$ sudo mysql.server start
Starting MySQL
. SUCCESS! 

Hope that helps. If the above doesn't work for you, try to run the mysqld_safe binary manually in the Cellar/mysql/VERSION_/bin/ directory and check what the settings are (if it runs)

sudo /usr/local/Cellar/mysql/5.6.12/bin/mysqld_safe &

If that runs, you can

ps aux | grep mysql 

and see something like

[username]  6881   0.0  2.7  3081392 454836   ??  S     8:52AM   0:00.54 /usr/local/Cellar/mysql/5.6.21/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.21 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.21/lib/plugin --verbose --log-error=/usr/local/var/mysql/BOXNAME.local.err --pid-file=/usr/local/var/mysql/BOXNAME.local.pid

I'm not sure why that worked for me but it shows you where I got the my.cnf config file options from. You can also use the command line options to try to troubleshoot when starting mysqld manually.

If you do run manage to run MySQL server using mysqld_safe, you may have to do this to shut it down before trying the mysql.server bash helper. Resist the urge to kill -9 [PID] because you can corrupt your data.

mysqladmin -uroot shutdown

Good luck!

查看更多
啃猪蹄的小仙女
5楼-- · 2019-01-12 17:28
sudo chmod -R 777 /usr/local/var/mysql/

works for me.

查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-01-12 17:29

I ended up with completely reinstalling of mysql, and it finally worked out.

WARNING This will remove all of your databases, so make sure to save dumps first.

brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql

brew install mysql
mysqld --initialize --explicit_defaults_for_timestamp
mysql.server start # no sudo!
查看更多
Fickle 薄情
7楼-- · 2019-01-12 17:29

While Installing from source,please follow the instruction in file INSTALL-SOURCE

where installation instruction are given in section 2.8

after installation ,check are there any process running of mysql with ps aux | grep mysql

You'll find like this

root      1817  0.0  0.0 108336  1228 ?        S    Jan21   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mail.gaurav.local.pid
mysql     2141  0.0  1.2 497660 24588 ?        Sl   Jan21   0:26 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mail.gaurav.local.err --pid-file=/usr/local/mysql/data/mail.gaurav.local.pid --socket=/tmp/mysql.sock --port=3306
root      5659  0.0  0.0 103256   840 pts/13   S+   11:30   0:00 grep mysql

kill all process related to mysql,and then try to start mysql server

查看更多
登录 后发表回答