Use these options by gem install mysql2 -- [--optionA] [--optionB=argument]. --with-mysql-dir[=/path/to/mysqldir] - Specify the directory where MySQL is installed. The mysql2 gem will not use mysql_config, but will instead look at mysqldir/lib and mysqldir/include for the library and header files. This option is mutually exclusive with --with-mysql-config. --with-mysql-config[=/path/to/mysql_confi