Saturday, August 24, 2013

How to log every query in MySQL on Fedora

In /etc/my.cnf, in the [mysqld] section, add the following 2 lines:

general_log=1
general_log_file=/var/log/mysql.log

Then:

sudo su
touch /var/log/mysql.log
chown mysql:mysql /var/log/mysql.log

Restart mysqld:

sudo /sbin/service mysqld restart

Note that the "log" variable in my.cnf is now deprecated, and doesn't log files in Fedora 14.


Friday, August 23, 2013

How to Install MongoDB on Fedora

If you are using the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/ they say to create a file called /etc/yum.repos.d/10gen.repo - but if you try that, you may be getting the following error when trying to start the mongod service.

It turns out that mongodb is built into fedora (via yum), so you don't need to add the 10gen.repo file.  Here's how to install mongodb on Fedora:

1) Uninstall mongodb:

yum erase mongodb
yum erase mongo-10gen

2) Remove the 10gen.repo file

rm /etc/yum.repos.d/10gen.repo

3) Install mongodb via default yum

yum install mongodb mongodb-server

4) Start monogodb service

/sbin/service mongod start


Tuesday, August 20, 2013

Friday, August 16, 2013

Why won't MySQL Workbench let me add a Foreign Key relationship?

You might be unable to check the desired foreign column box in MySQL Workbench.

If you are trying to add the foreign key on the command line, then you may also be getting "a can't create table 150 alter table" and Error Code 1005 error.

Make sure that you have the table and column names correct.

Also make sure that the two columns are EXACTLY the same type.  Check for int(10) vs int(11) and int(10) vs int (10) unsigned.  They have to be EXACTLY the same type.  MySQL Workbench may not show or let you change int(10) to int(10) unsigned, but you can check the exact column type using "show create table", and you can change it on the command line like this:

ALTER TABLE TableName CHANGE columnName columnName  int(10) unsigned DEFAULT NULL

After this, you should be able to check the desired box in MySQL Workbench.

Also, make sure that both tables are using InnoDB

Also see: http://stackoverflow.com/questions/9018584/error-code-1005-cant-create-table-errno-150

Monday, August 12, 2013

How to recover found.000 folder that is locked

On Windows 7, if chkdsk recovers a found.000 folder, and you can't access it, and if changing ownership to you doesn't work, try this simple trick:

Copy the folder to another area.

Then try to access the copy of that folder.

For some reason, it works for me.