Tuesday, November 17, 2015

MySql Start / Stop / Restart



I was experiencing following error in my mac after i upgraded to Yosemite.

Shammis-MacBook-Pro:~ shammi$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


Then i went through so many ways to get rid of the issue. Finally this advise made it working. I found that from here.

Create /Library/LaunchDaemons/com.mysql.mysql.plist and save it with the following plist:


  1. xml version="1.0" encoding="UTF-8"?>  
  2. >  
  • <plist version="1.0">  
  •   <dict>  
  •    <key>KeepAlive</key>  
  •    <true/>  
  •    <key>Label</key>  
  •    <string>com.mysql.mysqld</string>  
  •    <key>ProgramArguments</key>  
  •    <array>  
  •    <string>/usr/local/mysql/bin/mysqld_safe</string>  
  •    <string>--user=mysql</string>  
  •    </array>  
  •   </dict>  
  • </plist>  



  • And also changing some permisions to the file:

    sudo chown root /Library/LaunchDaemons/com.mysql.mysql.plist
    sudo chgrp wheel 
    /Library/LaunchDaemons/com.mysql.mysql.plist
    sudo chmod 
    644 /Library/LaunchDaemons/com.mysql.mysql.plist

    And finally load the plist:

    sudo launchctl load -/Library/LaunchDaemons/com.mysql.mysql.plist


    In the same time, It will be useful to know following which i found from [1]

    To restart, start or stop MySQL server from the command line, type the following at the shell prompt…

    On Linux start/stop/restart from the command line:

     /etc/init.d/mysqld start
     /etc/init.d/mysqld stop
     /etc/init.d/mysqld restart
    Some Linux flavours offer the service command too
     service mysqld start
     service mysqld stop
     service mysqld restart
    or
     service mysql start
     service mysql stop
     service mysql restart

    On OS X to start/stop/restart MySQL from the command line:

     sudo /usr/local/mysql/support-files/mysql.server start
     sudo /usr/local/mysql/support-files/mysql.server stop
     sudo /usr/local/mysql/support-files/mysql.server restart

    No comments:

    Post a Comment