Sunday, April 26, 2009

Setting up MySQL on DNS-323

It took me awhile to get round to this (more than a year apparently) but I finally managed to get it done over the weekend. The trigger was because I am going to get a SqueezeBox Boom and will be running the associated controller software called SqueezeCenter (which requires the MySQL database) off the DNS-323.

Compared to the last time I was looking at doing this, the installation and setup is now a breeze, all thanks to fonz for creating a funplug package for it:
  1. Download the package from fonz's website
    # wget
  2. Install the package
    # funpkg -i mysql-5.0.67-2.tgz
  3. Setup the MySQL config file using the small version of the included examples (remember that the DNS-323 has limited resources)
    # cp -a /ffp/etc/examples/mysql/my-small.cnf /ffp/etc/my.cnf
  4. Define a storage location for your database files in the config file. For me, I have it on my USB stick as my usage pattern is mostly reads and I want to my HDD to remain in spin down state longer. Add in my.cnf after [mysqld] : datadir = /ffp/var/mysql
  5. Initialize MySQL
    # mysql_install_db
  6. Now create a database and have fun!
    # mysql -u root -p
    Enter password: your_root_password

    mysql> create database testdb;
    mysql> grant all on testdbuser.* to testdb identified by 'your_password';
    mysql> flush privileges;
    mysql> quit

  7. In case of errors, look up the log found in /ffp/var/mysql/[replace with your hostname].err

Besides using it with SqueezeCenter, I intend to also use it for some web-app projects (e.g. Joomla!). Stay tuned!


Y said...

What about creating and setting up a mysql user (and changing ownership of mysql directories:
chown -R mysql /ffp/var/run/mysql
chown -R mysql /ffp/var/mysql

Is it required? Did I need to do it to start mysql running?



Y said...

Also, the following error:
root@dlink-XXXX:/mnt/HD_a2/ffp/var/mysql# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

means password wasn't set for root user
/ffp/bin/mysqladmin -u root password 'passcomeshere'

This is probably a mysql standard routine, but since I, and probably others might not be mysql admins, can be a showstopper.


Anonymous said...

On DNS-320, the install script isn't complete. You must first create the mysql user, and THEN run the install script :

useradd -U -s /bin/false mysql
funpkg -i mysql-5.0.67-2.tgz

And, once the install is over, the init script must be made executable so mysql is launched automatically at boot time of the NAS :

chmod a+x /ffp/start/

Anonymous said...


"# mysql -u root -p"

i get an error 2002 (HY000): Cant connect...

should i type a command :

"sh start" ?

thanks in advance.