I sometimes feel as if I spend half my time making fixes caused by Apple upgrades.
This morning I found my previously hand-crafted php.ini had been removed.
So, each time Apple does an upgrade I have to go back in and update php.ini with various customizations (like max post size, etc).
This also happened to Apache. Apple did an upgrade and I lost my virtualhosts.
And other things change too – like I now have to use mysql.server start rather than using mysqld. I can understand that things need to change but why not provide a graphic tool and just change things under the hood.
Now I try restarting MySQL and I get:
<span class="s1">Starting MySQL
</span>. ERROR! The server quit without updating PID file (/usr/local/var/mysql/my.local.pid).
So clearly another update has happened that I’ll need to fix.
My experience on Linux has always been much smoother. I’m starting to wonder if I should try using it again as a development platform.
Nine times out of ten this is down to a table that hasn’t been indexed properly.
to see your MySQL processes. Check out the ‘time’ column.
To add an index use:
table ADD INDEX
If you use the init.d script on Ubuntu, e.g.
sudo /etc/init.d/mysql restart
you may get this message:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mysql ; start mysql. The restart(8) utility is also available.
mysql start/running, process 25974
Wondering whether to use phpMyAdmin or
If you’re on the Mac use Sequel Pro:
Or there’s a Rails app called DB explorer:
Latin is a single-byte encoding.
So, non-Latin characters will break if you try to display them using a Latin encoding.
UTF-8 is potentially a 3 byte encoding and can encode a great deal more.
Here’s a Unicode/UTF-8 character table:
If you’re using MySQL, here’s how to ALTER the table to convert to the UTF-8 character set. Note there’s a slight subtlety here in that, because of the extra bytes used by UTF-8, unless you specify the column type it might roll over to the next larger column type size. E.g. for VARCHAR:
ALTER TABLE table_name MODIFY column_name VARCHAR(255) CHARACTER SET utf8;
select * from mysql.user;
UPDATE mysql.user SET Password=PASSWORD(‘password-here’) WHERE User=’your-user’ AND Host=’localhost’;
mysql -u<username> -p<password> -h<hostname> <database_name> < dump.sql
Say you want ORM with a console script.
Here’s how you could do it using ActiveRecord without Rails.
1. create a database YAML file (a la Rails)
2. Use the ActiveRecord::Base.establish_connection
Super simple. E.g.
dbconfig = YAML::load(File.open(‘database.yml’))
class People < ActiveRecord::Base
(assuming you had a MySQL database table called ‘people’) with a database.yml like this:
and you could log it using:
ActiveRecord::Base.logger = Logger.new(STDERR)
From Katz’ great post:
Specifying groups allows you to do two things. First, you can install the gems in your Gemfile, minus specific groups. For instance, Rails puts mysql and pg in a database group so that if you’re just working on ActionPack, you can bundle install –without db and run the ActionPack tests without having to worry about getting the gems installed.
Second, you can list specific groups to autorequire using Bundler.require. By default, Bundler.require requires all the gems in the default group (which is all the gems that have no explicit group). You can also say Bundler.require(:default, :another_group) to require specific groups.
Snow Leopard is a gnarly old beast.
However, I left my Mountain Lion laptop with someone when visiting and needed to use my old backup Mac running Snow Leopard.
Some hints on how to get stuff (MySQL / Rails) working: