A simple request - add SQL file to Resources section

Post Reply
codiddle
Posts: 56
Joined: Sat Aug 11, 2012 12:58 pm

A simple request - add SQL file to Resources section

Post by codiddle » Sat Jan 25, 2014 2:31 pm

There's a SQL file Thrydwolf wrote on the Wiki for automating the process of building the DB for the server. Is there anyway that can be included in the Resources section of the phpbb site, or maybe dropped into the Custom Tools and Application section for easier access? I'll quote it so it's easy,
@ECHO OFF
REM =============================================================================
REM =============================================================================
REM ====== =========
REM ====== THis script will drop the DB specificed, then create the DB =========
REM ====== specified, and then load all .sql tables from its run dir to =========
REM ====== the the DB. =========
REM ====== =========
REM ====== File needs to be run from within the \dsp\sql folder (same =========
REM ====== folder with all the .sql files. Please edit as needed. By =========
REM ====== default it WILL DROP the standard dspdb DB, loosing all =========
REM ====== accounts and characters. If this is not desired, then update =========
REM ====== the file to load the new DB into a new DB name. =========
REM ====== =========
REM ====== Update -p with MySQL password. If you password is 'foo', =========
REM ====== then change '-pMYSQLPASS' to '-pfoo' (3 places). =========
REM ====== =========
REM ====== If you want to use a different database name, change 'dspdb' =========
REM ====== with a database name of your choosing. =========
REM ====== =========
REM =============================================================================
REM =============================================================================
REM ====== =========
REM ====== by Thrydwolf 9/8/2012 =========
REM ====== Updated with status by bluekirby0 3/30/2012 =========
REM ====== Updated by Thrydwolf 9/18/2012 =========
REM ====== =========
REM =============================================================================
REM =============================================================================

ECHO Creating Database dspdb
mysqladmin -h localhost -u root -pMYSQLPASS DROP dspdb

ECHO Creating Database dspdb
mysqladmin -h localhost -u root -pMYSQLPASS CREATE dspdb

ECHO Loading dspdb with tables
REM FOR %%X IN (*.sql) DO mysql dspdb -h localhost -u root -pMYSQLPASS < %%X
FOR %%X IN (*.sql) DO ECHO Importing %%X & mysql dspdb -h localhost -u root -pMYSQLPASS < %%X

ECHO Finished!

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: A simple request - add SQL file to Resources section

Post by kjLotus » Sat Jan 25, 2014 2:55 pm

it's on the wiki already in "Building the Server" but i don't see why not

EDGECOM
Posts: 50
Joined: Sat Aug 04, 2012 8:31 am

Re: A simple request - add SQL file to Resources section

Post by EDGECOM » Sun Jan 26, 2014 1:35 pm

that barch file I could never get to work how ever the one below works perfect

NOTE: if you change the password make sure there is a -p or the script will fail

Code: Select all

@ECHO OFF
REM ====== by EDGECOM 1/26/2014
REM copy over the mysql.exe from the server bin folder into the darkstar sql folder
REM FROM C:\Program Files\MySQL\MySQL Server 5.6\bin\
REM TO C:\darkstar\sql\

REM if you changed the default mysql instlation folder please change this to the propper dir
cd "C:\Program Files\MySQL\MySQL Server 5.6\bin\"

ECHO Creating Database dspdb
mysqladmin.exe -h localhost -u root -proot DROP dspdb

ECHO Creating Database dspdb
mysqladmin.exe -h localhost -u root -proot CREATE dspdb

REM change this to your server folder if its not default
cd "C:\darkstar\sql\"

ECHO Loading dspdb with tables
REM FOR %%X IN (*.sql) DO mysql dspdb -h localhost -u root -ppassword1! < %%X
FOR %%X IN (*.sql) DO ECHO Importing %%X & mysql dspdb -h localhost -u root -ppassword1! < %%X

del "mysql.exe"

ECHO Finished!


User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: A simple request - add SQL file to Resources section

Post by atom0s » Sun Jan 26, 2014 2:24 pm

You need to add the path to MySQL's bin files to your systems environment variables for it to work from any location.

EDGECOM
Posts: 50
Joined: Sat Aug 04, 2012 8:31 am

Re: A simple request - add SQL file to Resources section

Post by EDGECOM » Sun Jan 26, 2014 3:34 pm

True I forgot about that lol

hum maybe I should make a sql import tool that will auto import if it finds newer time stamp on file..

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: A simple request - add SQL file to Resources section

Post by atom0s » Mon Jan 27, 2014 3:56 am

Auto-imports on things like the char data tables and such will still need to be mended by hand to prevent killing the current character data. There are multiple files that will have to have that restriction. It's generally easier to just follow the changes and do the updates manually.

Post Reply