Archive | MySQL RSS feed for this section

How to set lower_case_table_names in MAMP

4 Nov

Environment – Mac OS X
I have struggled a little to set lower_case_table_names =2 for mysql using MAMP. I have unsuccessfully tried configuring /etc/my.cnf and ~/.my.cnf. Finally (with a little help) I found that they are setting this value in MAMP/bin/startMysql.sh . Location of this file might differ because in your version of MAMP.
My config file looks like this

# /bin/sh
/Applications/MAMP/Library/bin/mysqld_safe --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=2 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &

Change this file to set it to required value. As you might have guessed, you can use the same approach to update other params like log-error location, or port number (port number can be changed from MAMP preferences too)

How to switch to INNODB database in mysql

8 Jun

MySQL support many storage engines. If you run the following command you can see all the storage engines supported by your mysql version.


show engines;

For the performance reasons MyISAM is the default storage engine.  In some cases, you might want to change this to different engine, like  InnoDB for transaction support etc.

There are couple of ways of doing it. I know three of them

1. Change my.cnf file.

MySQL reads from my.cnf to read the default configuration settings. This file is generally found in /etc/my.cnf or $USERHOME/.my.cnf in *nix/mac  or c:\ or installdirectory or windows directory in window. In my.cnf file have this configuration


[mysqld]
.........

.........
default-storage-engine = InnoDB

Also, have the following  lines or uncomment them if already present. Make sure the innodb_data_home_dir etc points to a valid location

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

2. SET storage_engine=INNODB

If you want your storage engine changed to something else for just the current session you can run the following command

SET storage_engine=InnoDB

3. Use engine=INNODB per table

You can change the engine per table like this

CREATE TABLE employee (id INT) ENGINE = InnoDB;

or if you have existing table and you want to change the engine

ALTER TABLE employee ENGINE = InnoDB;

Error while configuring mysql for Alfresco

4 Jun

Today while configuring mysql database for my Alfresco, I started getting these type of errors


com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate key name ......

This error was coming when it was running this script

/opt/alfresco/tomcat/temp/Alfresco/AlfrescoSchema-MySQLInnoDBDialect-Update-8823117053596272720.sql

Then I realized that mysql on my macine was not using INNODB engine by default. I dropped the database and created again using innodb engine and it worked

Hyphen in MySQL database

26 Aug

If you have hyphen(-) in your mySQL database you can use back-ticks to escape while issuing commands

like
drop database `alfresco-dev`;

10061 error while installing MySQL on Windows Vista

20 Jan

I really had a very tough time today while installing MySQL on vista. All the steps in the installation are simple and self-explanatory. I just want to mention two things from my experience

Before starting installation

1) If you want to install MySQL after uninstall, delete your current MySQL fully and properly. After uninstall you should manually delete the installation folder at c:\Program Files\MySQL or at any location your MySQL is installed.

2) Turn off UAC(the nasty part of Windows Vista)

3) Turn off Windows Firewall.

4) Restart your PC.

5) Try now. This time the installation should be smooth and easy

Follow

Get every new post delivered to your Inbox.