Sunday, December 28, 2008

MySQL data in /home direcotory

(following http://www.debianadmin.com/mysql-database-server-installation-and-configuration-in-ubuntu.html)

Here is the procedure how to change Mysql default data directory

By default, MySQL’s datadir is placed in the /var/lib/mysql directory.

Create the directory that will be new datadir (ex:-/home/db)

chown the directory to the mysql:mysql user

sudo chown -R mysql:mysql /home/db/*

You need to stop the mysql server using the following command

sudo /etc/init.d/mysql stop

Now you need to edit the /etc/mysql/my.cnf file

sudo vi /etc/mysql/my.cnf

and look for “datadir = /var/lib/mysql” this si where mysql database default data directory here you need to change this one to your new directory

datadir = /home/db

copy the files from the old datadir to the new location. However, make sure that the files named
ib_arch_log_0000000000, ib_logfile0 etc. are not copied to the newer location.

Make sure that the files and directories are owned by mysql user

Make changes in the my.cnf to point the new datadir.

Restart the MySQL database

sudo /etc/init.d/mysql start

----

Following: http://neodon.blogspot.com/2008/09/changing-data-directory-for-mysql-in.html

You simply edit /etc/apparmor.d/usr.sbin.mysqld. Underneath the two lines authorizing the default MySQL data directories, add two more with your custom directory. Make sure you have a trailing / on the directory name, otherwise it will not work (I had this problem at first). After this change, restart AppArmor:

sudo invoke-rc.d apparmor restart

Now you should be able to set up the new directory as a MySQL data directory and initialize it using mysql_install_db. For more information on this topic, check out the following links:

Thursday, December 04, 2008

Wyświetlanie Daty


strftime:

%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character

t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"