1 /* Copyright (C) 2000-2005 Thomas Bopp, Thorsten Hampel, Ludger Merkens
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 int main(int argc, array argv)
26 mapping conf = ([ "rootpw": "", "password": "steam", "user":"steam",
28 for ( int i = 1; i < argc; i++ ) {
31 if ( sscanf(argv[i], "--newroot=%s", val) == 1 ) {
32 Process.system("mysqladmin -u root password " + val);
34 else if ( sscanf(argv[i], "--password=%s", val) == 1 )
35 conf["password"] = val;
36 else if ( sscanf(argv[i], "--user=%s", val) == 1 )
38 else if ( sscanf(argv[i], "--rootpw=%s", val) == 1 )
40 else if ( sscanf(argv[i], "--db=%s", val) == 1 )
44 handle = Sql.Sql("mysql://root:"+conf->rootpw+"@localhost/mysql");
45 handle->big_query("create database " + conf->db);
46 handle->big_query("use mysql");
47 handle->big_query("grant all privileges on " + conf->db + ".* to "+
48 conf->user + " @localhost identified by '" + conf->password+
49 "' with grant option;");