Total Pageviews

Saturday, April 11, 2015

Setting Password for new Mysql database on MAC

http://stackoverflow.com/questions/6474775/setting-the-mysql-root-user-password-on-os-x

Try the command FLUSH PRIVILEGES when you log into the MySQL terminal. If that doesn't work, try the following set of commands while in the MySQL terminal
$ mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
Change out NEWPASSWORD with whatever password you want. Should be all set!


If you don't remember the password you set for root and need to reset it, follow these steps:
  1. Stop the mysqld server, this varies per install (on my MAC: sh-3.2# mysqld stop)
  2. Run the server in safe mode with privilege bypass
    sudo mysqld_safe --skip-grant-tables
  3. In a new window connect to the database, set a new password and flush the permissions & quit:
    mysql -u root
    UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
    FLUSH PRIVILEGES;
    \q
  4. Stop the safe mode server and start your regular server back. The new password should work now. Worked like a charm for me :)

On Mac OSx Mavericks (2014) use sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop|start|restart 

No comments: