Blake Simpson

Login as root with no password on MySQL 5.7.9 with El Capitan (Homebrew)

Wednesday 18th of November 2015

The MySQL version that will be installed through Homebrew for El Capitan is currently version 5.7.9. This is an upgrade from the 5.6.x versions that brew would install on previous OS X versions.

This new version of MySQL has some security features and syntax changes that may be confusing. Personally after installing through Homebrew I did not know the default password and wanted to set up the server to accept the root user with no password, for my development environment. Read on to see how I achieved this.

Getting the a root user with no password

Run the following highlighted steps in the Terminal.

  • Lines prefixed with "$" are a terminal command.
  • Lines prefixed with "mysql >" are entered in the MySQL command line client.

Stop the server

$ mysql.server stop

Also unload the launchctl file, if you have one, to prevent the server restarting:

$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Starting Safe Server

Now that MySQL has stopped running, you can start the mysqld_safe process. We use the --skip-grant-tables option to prevent permission errors when trying to update the password later.

$ mysqld_safe --skip-grant-tables &

Reseting the password: Part 1

Next we will enter the MySQL command line and ask the server to change the remove the password for the "root" user.

$ mysql -u root

mysql> use mysql;
mysql> UPDATE user SET authentication_string=PASSWORD('') WHERE User = 'root';
mysql> exit

You may notice that in MySQL 5.7.6+ the password field has been changed to authentication_string.

Reseting the password: Part 2

Now that the login password has been set, we can kill the safe server:

$ killall mysqld

Next restart the "real" MySQL server. This will take a few moments.

$ mysql.server start

Now we can log in to MySQL successfully as the root user with no password. Login with the following command (when prompted for the password, don't type anything, just hit enter):

$ mysql -u root -p
Enter password:

Now the process gets confusing. You are logged in as root successfully but try to run use mysql;, you see the following error:

mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

Now you must set the password again using the new MySQL 5.7.6 method (ALTER USER):

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '';


Finally we are done. You can exit the MySQL CLI using the exit command and are back to the terminal. You can try to log in again and access your tables and not experience any errors.

If you wish you can now reload the launchctl plist for MySQL so that the server starts automatically when your computer does.

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Read More Comments

Fix Homebrew error "/usr/local/bin is not writable" on OS X El Capitan

Tuesday 17th of November 2015

For some reason since the El Capitan upgrade the /usr/local/bin and /usr/local/share directories are not owned by the current logged in user. This means that Homebrew is not able to access these locations and add the files it needs to install software for you on OS X.

To fix this you will need to use chown in the Terminal application to reclaim permissions for these directories. Open up a terminal and run:

sudo chown -R `whoami`:admin /usr/local/bin

You will be prompted for your password when using the sudo command.

Then run:

sudo chown -R `whoami`:admin /usr/local/share

Now you can rerun your brew install command.

Note: If you have already installed the homebrew package, you will simply need to link it instead. If you see an error similar to:

brew install the_silver_searcher
Warning: the_silver_searcher-0.31.0 already installed, it's just not linked

Then simply run:

brew link the_silver_searcher

Do you run Sophos Antivirus?

I have heard that currently there is a problem with Sophos on El Capitan. When its scans your computer it will touch the /usr/local/ directory and affect the permissions. Sophos are working on a fix for this but currently you may discover permission problems even without a log out or system reboot.

Read More Comments

Fix locked OS X volume controls

Sunday 12th of July 2015

If your Mac audio controls are locked (greyed out in the control menu and the keyboard buttons don't work), you can open up the Terminal application and run the following command:

sudo killall coreaudiod

You will be prompted for your password and then your audio controls will restart, brining them back to life.

Read More Comments

Prevent the Cordova web view from bouncing

Sunday 7th of June 2015

When building an iOS project with Cordova the setting that allows web views to bounce will be turned on by default, resulting in an effect while scrolling that can look ugly, like so:

My FIlm List web view bounce

Since Cordova versions 1.5+ the cordova.plist file has been replaced with the config.xml that you find in the root directory of your Cordova project. This is where you set the configuration property to inform iOS to disable web view bouncing.

Instead of editing a plist file in XCode, instead we will add the configuration to the /your-project/config.xml file. Open this file with a text editor and add the line to the end of the <widget> block, before the final </widget>.

<preference name="DisallowOverscroll" value="true" />

Now rebuild the iOS application from the terminal.

cordova build ios

When you next run the application in XCode on a simulator or device, the bouncing problem will be solved.

Read More Comments

Sorting a German date format in Tablesorter.js

Friday 15th of May 2015

The German date format is 01.05.2015 as opposed to the UK date format 01/05/2015 which Tablesorter.js comes prebuilt to parse.

To sort by a German date, you have to add a custom parser. Here is one that will work for a date with the German dot notation.

  id: 'dotDate',
  is: function (content) {
    return /\d{1,2}\.\d{1,2}\.\d{1,4}/.test(content);
  format: function (content) {
    content = content.replace(/\-/|:|\.|\//g,' ').split(' ');
    return $.tablesorter.formatFloat(new Date(content[2], content[1]-1, content[0]).getTime());
  type: 'numeric'

Simply add this parser and then tell your tablesorter initializer function which column the German date is in.

  headers: {
    0: { sorter: 'dotDate' }

If your date only has 2 numbers for the year instead of 4, you can adjust the is method to use the regex /\d{1,2}\.\d{1,2}\.\d{1,2}/.

Read More Comments

Customise the Atom fuzzy finder width using custom styles

Friday 8th of May 2015

I find for my projects that the fuzzy finder overlay dialog in the Atom editor is a little short for my liking. I often have long path names with the same file name so I and can't see the full path, therefore I am not sure which file I am choosing.

Atom fuzzy finder original size

The easiest way to do this is to use your custom stylesheet to alter the fuzzy finder interface. Open your Atom stylesheet via the menu options Atom -> Open Your Stylehseet.

Next paste in the following CSS code. Save the file and the Atom styles will automatically reload.

.modal.overlay {
  width: 800px;
  margin-left: -400px;

.fuzzy-finder {
  width: 784px;

Open the finder again and now it looks much better!

Atom fuzzy finder after width customisation

Of course you may want to customise the widths of the modal to fit your workspace better.

Read More Comments

Getting started with the Atom Editor (and tips for switching from Vim)

Wednesday 29th of April 2015

Atom Logo

Today I started working with the awesome Atom Editor instead of my usual tool MacVim.

Atom is open source and free, produced by the people at GitHub. To introduce Atom, what can I say that they can't say for themselves?

Atom is a desktop application based on web technologies. Like other desktop apps, it has its own icon in the dock, native menus and dialogs, and full access to the file system.

Open the dev tools, however, and Atom's web-based core shines through. Whether you're tweaking the look of Atom's interface with CSS or adding major features with HTML and JavaScript, it's never been easier to take control of your editor.

So basically Atom is a code editor built on top of a browser. Meaning, as a web developer you already have all the skills needed to extend the code base, or write a custom Atom package (plugin). Due to Atom being based on a browser engine (Blink) you even have the usual Chrome developer tools available to you!

Atom Editor preview showing Dev Tools

Why Change?

The main reasons I am trying out a new editor are:

  • Ease of use - Vim is powerful but can be painful too
  • Packages - Atom is easy to extend and has a large community, no Pathogen or Vundler required
  • Customisation - I'm a web developer, making packages easy to write
  • Teamwork - Many colleagues don't know Vim, or at least everyone has different key bindings
  • Look and feel - Atom is beautiful

Some Tips for Beginners

Key Combinations

Arguably the most attractive feature of Vim is the powerful key combinations + motions. For example, in Vim you can type 10dd to delete the next 10 lines. Atom does not have this built in, although there is of course a package for that, many of the more common combinations are available by default. A few useful ones that helped me switch are:

Read More Comments

Cordova plugins not working on iOS? Fix the Target Membership

Monday 27th of April 2015

If you have installed a Cordova plugin and it is not working on iOS, for example the expected JavaScript object for the plugin simply doesn't exist. But you have tested and find that the functionality is working fine on Android, this is usually a symptom of an error in the iOS plugin class target membership.

For example this can often happen with the Cordova SplashScreen plugin. See the screenshot below and ensure that the .m implementation file has a checkmark on the "Target Membership" option for your application.

XCode target membership preview

Only the implementation file should have the target membership checked (so not the .h header file).

This is often the reason why a plugin appears simply not to work. It's always good to check this setting first before debugging further.

Read More Comments