patternsqlMinor
MySQL specific database configuration file
Viewed 0 times
filedatabasemysqlspecificconfiguration
Problem
In MySQL's configuration file I've globally disabled autocommit as so.
I need to turn MySQL's autocommit on for a specific Ruby on Rails database though. It could be for the user or the database itself (doesn't matter). Thinking it would look something like this.
[mysqld]
autocommit=0I need to turn MySQL's autocommit on for a specific Ruby on Rails database though. It could be for the user or the database itself (doesn't matter). Thinking it would look something like this.
[mysqld]
autocommit=0
execute_sql="Custom SQL to set autocommit for a database"Solution
Let's say
You could use the init-file option
You could just create an init file called
Put the customer SQL in
You could then try one of two things
Try #1
Add this to
then run
Try #2
Directly run this
Give it a Try !!!
CAVEAT
That was a global setting of init code. If your session has to enable autocommit, then just run
in the session or put
UPDATE 2013-02-28 15:40 EST
If you are looking for a startup option for my.cnf to affect the client, try this:
or
Perhaps try adding another
For more information, see the MySQL Options File Documentation
- you are using MySQL in Linux
- datadir is
/var/lib/mysql
You could use the init-file option
You could just create an init file called
/var/lib/mysql/init-file.sqlPut the customer SQL in
/var/lib/mysql/init-file.sqlYou could then try one of two things
Try #1
Add this to
/etc/my.cnf[mysqld]
init-file=/var/lib/mysql/init-file.sqlthen run
service mysql restartTry #2
Directly run this
service mysql restart --init-file=/var/lib/mysql/init-file.sqlGive it a Try !!!
CAVEAT
That was a global setting of init code. If your session has to enable autocommit, then just run
SET autocommit=0in the session or put
SET AUTOCOMMIT=0 in the init-file option file. This may still not produce the effect you want since everything goes back to default settings upon connection termination.UPDATE 2013-02-28 15:40 EST
If you are looking for a startup option for my.cnf to affect the client, try this:
[client]
autocommit=0or
[mysql]
autocommit=0Perhaps try adding another
my.cnf in the Linux home directory with these optionsFor more information, see the MySQL Options File Documentation
Code Snippets
[mysqld]
init-file=/var/lib/mysql/init-file.sqlservice mysql restartservice mysql restart --init-file=/var/lib/mysql/init-file.sqlSET autocommit=0[client]
autocommit=0Context
StackExchange Database Administrators Q#35700, answer score: 2
Revisions (0)
No revisions yet.