Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    16

    Run MySQL commands

    I am using SS 6.5.4 on SlimNAS using the inbuilt SS MySQL instance. I would like to be able to execute SQL scripts against the database every night via CRON.

    Do I need to install some more MySQL components, or is there something I can use in the default instance to execute these commands?

    Thanks,

    c0utta

  2. #2
    Senior Member
    Join Date
    Dec 2007
    Posts
    279

    Perl

    No mysql client in FreeNAS, but you could use perl as DBI works (what SlimServer uses) and all the supporting libraries are included in SlimNAS. SlimNAS disables user authentication for mysqld, so no need to usernames or passwords...

    Borrowing binaries from FreeBSD is also an option if you need a mysql client on the FreeNAS host.

    Other alternatives?

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    16

    Got it!

    Thanks syburgh, you have set me on the right path.

    I thought I could use some of the plugin code, but I found that I must reference DBI directly without referencing Slim.

    I also had to explicitly define the socket in the connection string.

    Anyway, the Perl code to execute SQL statements against the SS MySQL instance is:

    Code:
    use DBI;
    
    my $dbh = DBI->connect('DBI:mysql:host=localhost:mysql_socket=slimnas/var/slimserver/slimserver-mysql.sock;database=slimserver');
    my $sth = $dbh->prepare( "<type destructive SQL statement here>" );
    $sth->execute();
    Cheers,

    c0utta

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •