I bought a PC with Linux Mint 17 already installed. This is my first time working on a Linux system, so there's been a bit of a learning curve.
Things were going along pretty well until I started to get all kinds of weird errors.
• A text file that I maintain manually had the last part of its contents truncated from the last time I had saved it.
• I could not log in to phpMyAdmin even though I knew the username and password were correct.
• An initial install of Drupal 7 would not come up with its front page. A PDO error on a SQL query was being reported.
Eventually I suspected something related to databases, happened to run the Disk Usage Analyzer and found that one of the disk partitions had run out of space. Oh, joy.
It turns out that the system I got was configured with three partitions. On the File Systems tab of the System Monitor app, it shows the partitions and their total sizes as
/dev/sda1 /boot 463.9 MiB
/dev/sda5 / 18.6 GiB
/dev/sda6 /home 215.4 GiB
By default, MySQL 5.5 stores its data on /var/lib/mysql which is on the / partition which has about 18 GiB allocated to it.
That partition was not large enough for the Drupal 7 database along with everything else that was there, which apparently includes the system itself and apps that I had earlier installed.
Looking at these space allocations, I inferred that /home is where user data of all sorts is intended to be kept.
So I used the sources listed below to figure out how to change where MySQL stores its data.
(0) But first, I figured I should clean up the mess I had already created by uninstalling phpMyAdmin, and then completely uninstalling MySQL.
(I carried out all the commands in this post while logged in as root. Alternatively, you could use sudo instead.)
# apt-get remove phpmyadmin
# /etc/init.d/mysql stop
# apt-get remove mysql-server
# cd /var/lib
# rm -r mysql
# apt-get autoremove
That last command is to remove any packages that are no longer needed on the system. I'm pretty fussy about not keeping useless clutter around.
(1) Then, re-installed MySQL 5.5.
# apt-get install mysql-server
(2) Changed the MySQL data directory to use the much larger partition. In my case, I chose to put the data directly under /home
# /etc/init.d/mysql stop
# cp -R -p /var/lib/mysql /home
# cd /var/lib
# rm -r mysql
# ln -s /home/mysql /var/lib/mysql
That last command is to provide a symbolic link from the default directory to the real one. Otherwise, you can edit the datadir setting in the MySQL configuration file /etc/mysql/my.conf
Note that the MySQL logs are still located in /var/log/mysql
(3) The final step was to deal with the AppArmor app.
Edited /etc/apparmor.d/usr.sbin.mysqld to change from
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
to
/home/mysql/ r,
/home/mysql/** rwk,
I couldn't find the apparmor app mentioned in the source articles. Instead, I rebooted in order for these AppArmor security changes to take effect. (Could the AppArmor functionality be baked into the Linux Mint system?)
Sources:
How to change the MySQL data default directory
http://www.ubuntugeek.com/how-to-change-the-mysql-data-default-directory.html
Linux Ubuntu move mysql database to other path in 5 minutes
http://article.my-addr.com/?show=linux_ubuntu_change_datadir-move_mysql_database_to_other_path
How to Remove MySQL Completely from Linux System
http://tecadmin.net/remove-mysql-completely-from-linux-system/
No comments:
Post a Comment