How to Move MySQL's Data DirectorySometimes it becomes necessary to move the location where MySQL stores databases. Either you have run out of room or something else has happened and you need to modify MySQL's data directory. Here's how to do it.
First, I would stop MySQL's daemon if you aren't running production databases currently (which I would suggest reading this entire guide and thinking of a different way of doing this if you are):
sudo service mysql stop
Next, move or copy the current database directory. I copied it because I had room and I wanted to play it safe. For Ubuntu, the default MySQL database directory is
/var/lib/mysql, so to copy it I did:
sudo cp -R /var/lib/mysql /newdir/
newdir is where I want all of the MySQL databases and data to be.
Then you'll need to edit your MySQL configuration file. Edit
/etc/mysql/my.cnf and change this line
datadir = /var/lib/mysql
datadir = /newdir/mysql
newdir to your chosen directory.
Now, you'll need to change part of AppArmor's MySQL entry to reflect your new database directory. Edit
/etc/apparmor.d/usr.sbin.mysqld and change
/var/lib/mysql/ r, /var/lib/mysql/** rwk,
/newdir/mysql/ r, /newdir/mysql/** rwk,
newdir with your new directory. Now that you have changed everything, you can start MySQL again with
sudo service mysql start.
Automatically Mount a Drive when Linux BootsIf you want to have a drive (more specifically, a partition) mount when a GNU/Linux distro boots, simply add it to your
/etc/fstabfile. The fstab for Ubuntu usually looks like this:
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda1 during installation UUID=e25e0070-6617-47d6-8ff1-77d873d3879c / ext4 errors=remount-ro 0 1 # swap was on /dev/sda5 during installation UUID=62460a75-1863-4ee6-9c72-3b21aa64585d none swap sw 0 0
To mount the first partition (1) of the next drive (sdb) on boot, change the file to this:
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda1 during installation UUID=e25e0070-6617-47d6-8ff1-77d873d3879c / ext4 errors=remount-ro 0 1 /dev/sdb1 /media/mydrive ext4 errors=remount-ro 0 1 # swap was on /dev/sda5 during installation UUID=62460a75-1863-4ee6-9c72-3b21aa64585d none swap sw 0 0
Also, make sure you have created the mount directory and changed ownership to yourself:
sudo mkdir /media/mydrive sudo chown -R yourusername /media/mydrive
Create a Windows 8 Bootable USB Drive with Mac OS
Mac OS X 10.8 (Mountain Lion) makes it relatively easy to create a bootable USB drive for installing Windows 8. You don't have to be installing Windows 8 to the Mac, it will work on any computer that can boot from USB. I used Mac OS to prepare a bootable USB to install Windows 8 on a regular PC laptop. You will need the following:
- USB drive that is at least 4 GB
- Windows 8 ISO
To create the drive, open Bootcamp Assistant from the applications in Mac OS. Uncheck the box that says something about downloading Windows 7 updates, then continue. On the next screen, select the drive that you want to install the Windows 8 installer to and select the Windows 8 ISO file. Once you click next, Mac OS will format the drive and create a bootable Windows 8 USB drive with it.
If you need to create an ISO from a Windows 8 disk, this is how you would do that (from superuser.com):
"Disk Utility - The on-screen prompts will guide you, but it will by default create a .dmg, which is an OS X-specific file format. Disk Utility will also create an ISO (.cdr extension) if you select the "CD/DVD Master" option before creation the image. Rename the extension (to .iso) after creation if needed."
Title case a string in PythonWhile writing a python program, I came upon the need to convert a string to title case, or to capitalize the initial character of each word.
Although PHP has ucwords(), Python does not partake in the "two methods for everything anyone has ever thought about". Here's a small function to give you title cased strings:
def title_case(line): return ' '.join([s.upper() + s[1:] for s in line.split(' ')])
This will turn a string like "my fancy string" into "My Fancy String".
This page is now at <a href="http://example.com/url-you-want-to-redirect-to/"> http://example.com/url-you-want-to-redirect-to/ </a>, thanks!
Here is how you can redirect using PHP, if you access to it: Redirect with PHP.