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
Results 1 to 3 of 3
Thread: Run MySQL commands
-
2008-02-08, 18:40 #1Junior Member
- Join Date
- Dec 2007
- Posts
- 16
Run MySQL commands
-
2008-02-08, 21:26 #2Senior 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?
-
2008-02-09, 07:17 #3Junior 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:
Cheers,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();
c0utta

Reply With Quote
