Posts Tagged ‘mysql’
When you want to import the results of a query into a csv, you can use the following mysql query.
SELECT a,b,a+b INTO OUTFILE ‘/tmp/result.text’
FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘”‘
LINES TERMINATED BY ‘\n’
For some very easy repairs, this utility can be used.
myisamchk is an table-maintainence utility. It is used to repair corrupted mysql tables.
First, try myisamchk -r -q tbl_name (-r -q means “quick recovery mode”). This attempts to repair the index file without touching the data file. If the data file contains everything that it should and the delete links point at the correct locations within the data file, this should work, and the table is fixed. Start repairing the next table. Otherwise, use the following procedure:
Make a backup of the data file before continuing.
Use myisamchk -r tbl_name (-r means “recovery mode”). This removes incorrect rows and deleted rows from the data file and reconstructs the index file.
If the preceding step fails, use myisamchk –safe-recover tbl_name. Safe recovery mode uses an old recovery method that handles a few cases that regular recovery mode does not (but is slower).
Courtsey: Daniel Lorch
To install mysql bindings for ruby, use this command
#gem install mysql
You might get the following error:
“extconf.rb:1:in `require’: no such file to load — mkmf (LoadError)”
This probably means that you forgot to install the
ruby1.8-dev package. Just do an
apt-get install ruby1.8-dev to fix this.
Again after this you might this error:
“Could not create Makefile due to some reason [..] Check the mkmf.log file for more details. [..]”
You should do what the error message tells you: check the mkmf.log! Search for this file using
find /usr/lib/ruby/gems/1.8/gems/ -name mkmf.log. Usually, this error message appears because you forgot to install the
-dev package for the extension you were trying to install. So if you wanted to install the
mysql gem, you probably forgot to install the
libmysqlclient14-dev first. Do an
apt-cache search | grep dev to find the appropriate packages.
Courtsey: Simon Josefsson Datakonsult
No such file or directory – /tmp/mysql.sock
(See full trace by running task with –trace)
The problem is that you need the Ruby MySQL wrappers. This isn’t really clear from the error message. Install it using:
# apt-get install libmysql-ruby