Wednesday, December 16, 2009

Change innodb to myisam in mysql and separate single innodb file to multi files by table

I leave this blog for a long time because of health reason. Now I am back and hope that I can keep on with it.

Today I would like to talk about how to change a mysql database from using innodb engine to myisam. It started when I first use mysql database years ago. I knew nothing about it except that I needed a database. My first database use myisam engine and everything worked fine. Later, I think, mysql changed the default engine to use innodb. Since then my new database were all in innodb. Innodb provides more transaction control and management features, which for my application is really not necessary. I use innodb simply because it is the default and I didn't have the knowledge to concern about it. Until recently, I need to duplicate one database to another and found that innodb stores all databases into one single file. This makes duplicating database in file system level impossible.

So I went deeper into the documentation and search the internet to find a method to duplicate my databases.

All you need is your own mysql installation and your own databases in innodb. You also need sufficient space which is double the space of your database. Here it goes:

1. First step is of course to start up your mysql and your sql client.
2. If you have foreign key constraint in your database tables then you have to drop them because myisam does not support it. Use "alter table" command to drop all foreign key.
3. Use "alter table engine=myisam;" to change your table one-by-one to use myisam engine.
4. Check the folder that stores your myisam databases and you will find *.frm, *.myd, *.myi files. frm is the table definition, myd is the data and myi is the index. * is your table name. Then you can duplicate, copy your database (tables) to anywhere you like.
5. If you want to remain in innodb engine but use separate files for each table, innodb has an option that allows you to do so. Shut down your mysql, change the my.ini or my.cnf to include "innodb_file_per_table=1". Start your mysql again.
6. Use "alter table engine=innodb;" to change back to innodb engine. Use "alter table add constraint ...." to add back the foriegn keys.

I am not sure if the product of Step 5 and 6 can be copy/move in file system level. I understand in innodb, the frm file also stores where about of the data and index. So copy/move them to another folder may not work.

You may ask why didn't I use sqldump to duplicate databases? I haven't try it. But when I think of turn my multi-million rows table into a sql text file, I would rather hunt for another method.

Tuesday, April 15, 2008

DAC1794

This is not my first DIY project, but the first one I record in my blog. It was done about a year ago and I can only spare time to blog it lately.

Skip this paragraph if you know HiFi equipment well. For those who don't know HiFi or only use HiFi for music, DAC stand for digital-to-analog converter. It converts the digital signal from a, say, CD to analog signal that is required for amplifier and speaker. It is usually built inside the CD player of your HiFi set. For serious HiFi fever, they sometimes change the DAC to tune the sound quality of their HiFi set. Some CD player has digital output. Such output feeds into a DAC, like the one I posted here, to convert the digital signal.

This DAC is a DIY kit. In other words, I bought the whole and complete kit and assembled it myself. The kit includes all electronics, print circuit board, transformer, chassis, chassis accessaries and even power cord. Only the cables for internal connections and the human efforts are not included. I bought it via a local hifi diy forum, which organises group-buy from a China web site. The forum is here and the China web site is here. The forum is very well organised for group-buy. But when it comes to technical discussion, this English forum is much better because of international participants.

The DAC uses components:
  • LM2940T for +5V for digital
  • LM317, NE5532 for +5V and +3.3V for analog
  • TIP41C, NE5532 for +-15V for audio parts
  • CS8420 for digital input
  • PCM1794 for digital-to-analog conversion
  • NE5534 I/V
  • OPA604 low pass filter
  • 2SC1815 output buffer
The completed PCB:








This is the power supply part of the PCB with, from top, TIP42C, LM317 and LM2940.











This is the close-up of the IV, LPF and output parts. See the empty space in the middle of the PCB. It is for the optional LM337 to change the -15V rail to -10V for NE5534. -10V in NE5534 will make it work in Class A mode. I haven't take this path. A relay at the upper right corner. It is for delaying the output untill all components are initialized. There is a slightly demaged green capacitor near to the middle. This shows that my soldering skill needs to be improved. The components of the kit are all audio grade, though not really top of the market. But the C/P ratio is very high.

This is the last corner of the PCB. The CS8420 input chip at the lower part of the photo. Next to it is the crystal clock at 12MHz (??). The DAC 1794 itself is at the middle. 1794 is a SMD and needs the DIP converter to mount onto the PCB. Below it are jumpers to choose the operational modes of 1794. The two LED at the right is to indicate the power and locking status.



After soldering all the components on the PCB. I put it inside the chasis that comes with the kit. The wire at the bottom of the photo runs the AC power to the power switch at the lower right corner, and in turn to the primary of the transformer (also comes with the kit). There are 3 secondary from the transformer to the 3 power supply/regulator of the PCB. The digital input from CD player feeds into PCB via the coaxial at the upper left corner. The analog output runs from the lower part of the PCB to the RCA socket. Other wiring are for power, lock, and constant current source indicating LED.

This is the front of the chasis. There is a piece of plastic with transparent words purely for decloration. It needs some light from insider to make it visible at the front.


Here is how I did it. I use a straw with 2 blue LED at each end. When power is on, the LED light and reflected via the straw to illuminate the front plastic.




Finished. I put it under the CDM12 CD player (only the transportation, my other DIY project). Not bad, right? But I found that the power LED is too bright.


Then I changed it to a dimmer red LED and fine tuned the position of the illuminating straw.
That's all. Thanks for reading.

Starting

My first blog, please be gentle.

I finally decided to write blog of my own. Not an out-spoken person and so don't have much to say about myself. A typical techie interested in finding out how things work. So, when it comes to technical topics, I got lots of things to tell. And I like trying anything from hifi, to electronics, to micropocesser, to computer, to hardware and software etc. etc.

I think, give my background, my blog would be very much focus on my hobby listed at the header of my blog. So keep out if they are not your cup of tea. Otherwise, stay tune.