Total results: 15

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

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 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> FLUSH PRIVILEGES;
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 '';

Done!

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

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

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.

Fix locked OS X volume controls

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.

Sidekiq tasks for Capistrano 3

If using the Sidekiq gem with Capistrano version 3, you may like a simple set of start, stop and restart tasks. There are a few gems out there already built to help you with this, which might be suitable for your project. If you however just want a simple script then you may use this sidekiq namespace I wrote and tweak it to your needs.

Place the following in your deploy.rb

namespace :sidekiq do
  def sidekiq_pid
    current_path + '../shared/pids/sidekiq.pid'
  end

  def pid_file_exists?
    test(*("[ -f #{sidekiq_pid} ]").split(' '))
  end

  def pid_process_exists?
    pid_file_exists? and test(*("kill -0 $( cat #{sidekiq_pid} )").split(' '))
  end

  task :start do
    on roles(:app) do
      if !pid_process_exists?
        execute "cd #{current_path} && RAILS_ENV=#{fetch(:rails_env)} #{fetch(:rbenv_prefix)} bundle exec sidekiq -C config/sidekiq.yml -e #{fetch(:rails_env)} -L log/sidekiq.log -P #{sidekiq_pid} -d"
      end
    end
  end

  task :stop do
    on roles(:app) do
      if pid_process_exists?
        execute "kill `cat #{sidekiq_pid}`"
        execute "rm #{sidekiq_pid}"
      end
    end
  end

  task :restart do
    on roles(:app) do
      invoke "sidekiq:stop"
      invoke "sidekiq:start"
    end
  end
end

after 'deploy:restart', 'sidekiq:start'

Hide the iOS 8 status bar for better App Store screenshots

While working on my mobile application Elite Ice Hockey Action, I recently released an update and discovered that I need to add new App Store screenshots for the iPhone 6 and 6+.

Based on the App Store screenshot guidelines the images uploaded should not contain the iOS status bar (containing the time, battery level etc.). However, when using the iOS simulator for taking screenshots the status bar is always visible and simply cutting it out in Photoshop or Preview is not an option because since the iPhone 6 was released the screenshot dimensions must be exactly the same as the iPhone it was taken on.

There appears to be no way to simply turn off the status bar from the iOS simulator so my only option is to temporarily hide the status bar programmatically in Xcode and then disable this effect again after gathering my images.

Read on to find out the steps I performed to achieve this goal.

RubyMine: .ruby-version Gemset cannot be loaded

If you have installed RubyMine and the IDE complains that it cannot switch the Ruby SDK because the Ruby environment wasn't found based on your given .ruby-version file, try explicitly stating the ruby executable name.

This means simply change your .ruby-version from:

2.1.2

to:

ruby-2.1.2

Prevent "Outlook Office Reminders" reappearing on OS X

If you use Microsoft Outlook on OS X with the Exchange calendar, you will be familiar with the "Office Reminders" dialog window that will pop up and remind you of calendar events.

office reminders dialog

The problem is that this service will continue to pop up for events, even if you have closed the reminder application. Although the application has been closed and cannot be seen in the Dock, Outlook is actually running some background processes that prevent the reminders dialog from closing.

These processes can be stopped if wished, unfortunately in a not so user friendly manner, as you have to manually kill the processes using the Activity Manager.

To open the Activity Manager, open spotlight (⌘ + Space) and start typing "Activity" until you see the application.

Once open, you can filter for running processes, type "Microsoft" in the search bar in the top right.

filter activity monitor for microsoft processes

Finally once you can see these two processes "Microsoft Database Daemon" and "Microsoft Office Reminders", click on each one and click the "Force Quit" button which looks like a cross in a stop sign. Once the processes have ended, the pop up will no longer be able disturb you.

kill reminder process

Quickly open a web page in all browsers for testing

In order to test a certain web page in all of my development browsers, I wrote a simple shell script that will open a new instance of each of my browsers and automatically point it to a given URL.

This script is designed for OSX and will likely need some tweaks for a Linux distribution (or perhaps a complete rewrite) but the concept can be easily transferred.

browser-test.sh

# $1: URL

open -a "/Applications/Google Chrome.app" $1 -g -n
open -a "/Applications/Google Chrome Canary.app" $1 -g -n
open -a "/Applications/Safari.app" $1 -g -n
open -a "/Applications/Webkit.app" $1 -g -n
open -a "/Applications/Firefox.app" -g $1 -g -n
open -a "/Applications/FirefoxAurora.app" -g $1 -g -n
open -a "/Applications/Opera.app" $1 -g -n
open -a "/Applications/Opera Beta.app" $1 -g -n

I have configured the script to work for Chrome and Canary (Nightly), Safari and Webkit (Nightly), Firefox and Aurora (Nightly) and finally Opera and Opera Beta (Nightly).

On my setup I additionally load an extra app called "CoRD" which is used to connect to remote Windows machines for Internet Explorer testing.

browser-test.sh

open -a "/Applications/CoRD.app" -g -n

The -g option after each open command tells the given app to open in the background. Finally the -n switch will force a new instance of the browser, even if you already have one running, so that the browser is in a clean state to test with.

Finally I symlink this file to my /usr/local/bin directory so that the script is always available on my PATH.

Terminal

$ cd /usr/local/bin
$ ln -s browser-test ~/path/to/browser-test.sh
$ chmod a+x browser-test

Complete these steps in order and you will be able to call browser-test from any directory in the terminal.

Terminal

$ browser-test http://blog.blakesimpson.co.uk/

© Blake Simpson, 2012 – 2017