Possibly a silly question: Can I install MySQL on an External HDD connected to my Router?

Posted on

Question :

I have a 1TB Western Digital External HDD and I was wondering if I can turn it into a MySQL Database? The HDD itself is connected to my router via USB (BT Home Hub 3) and I would like to experiment with some database ideas at home. Is there any special steps I can take to do what I seek, or is it a hopeless endeavour?

Answer :

It is not a silly question as these days when databases are growing beyond gigs this is becoming a common practice. You can do that by moving all your files in current data directory to the new location and make changes in (datadir) in your my.cnf / my.ini accordingly

  1. Stop MySQL (service mysql stop)

  2. Make a dir in the HDD (mkdir /mysqldata)

  3. Move your data files to HDD (cp -rp /var/lib/mysql/* /mysqldata)

  4. Search datadir in my.cnf (cat /etc/mysql/my.cnf | grep datadir )

  5. Change path accordinly (datadir = /var/lib/mysql To: datadir = /mysqldata )

  6. Start MySQL (service mysql start)

Leave a Reply

Your email address will not be published.