Here is a basic MYSQL setup for Windows 7/8 32bit or 64bit for newbies.
Go to mysql web site and download the community Server version - mysql 5.5 ZIP archive
(yes there is a 5.6 But this tutorial was done with 5.5)
Choose the 64bit version if your Windows is 64bit.
http://dev.mysql.com/downloads/mysql/5.5.html#downloads
I got a zip file called
mysql-5.5.33-winx64.zip
Unzip it to a folder called mysql. Arrange the contents so that the sql files are just sub-parents of your mysql folder.
I put these in the root of my F: drive for ease of access.
Now inside mysql folder you should see a
my-large.ini file. Copy this to the same place but call it
my-dayz.ini
This will be your mysql startup initialization settings.
Open this file with a text editor.
Look for a line that says:
If you are happy to use this port then leave alone, otherwise if you have this port number already in use set it to a different number. ie 3310, 3312, etc.
Save file.
Now create a batch file called
START_MYSQL.BAT and place it within the
mysql folder.
Make it like this:
Code:
@ECHO OFF
set mysqlport=3306
set mysqlpassword=
CLS
ECHO.
ECHO SQL STARTED
ECHO.
CLS
ECHO.
ECHO.
tasklist /FI "IMAGENAME eq mysqld.exe" 2>NUL | find /I /N "mysqld">NUL
if "%ERRORLEVEL%"=="1" (
@start bin\mysqld.exe --defaults-file=my-dayz.ini & echo "Please wait...Loading MySQL" & ping -n 8 127.0.0.1>nul
)
REM tasklist /FI "IMAGENAME eq mysqld.exe" 2>NUL | find /I /N "mysqld">NUL
if "%ERRORLEVEL%"=="1" (
@start bin\mysqld.exe --defaults-file=my-dayz.ini --standalone --console & echo "Please wait...Loading MySQL" & ping -n 8 127.0.0.1>nul
)
ECHO MYSQL IS RUNNING
ECHO.
ECHO PRESS A KEY TO SHUT IT DOWN
ECHO.
PAUSE
ECHO DB shutting down.....
"bin\mysqladmin" -u root -p%mysqlpassword% --port=%mysqlport% shutdown
ECHO MYSQL HAS SHUTDOWN
timeout /t 3
taskkill /IM mysqld.exe /F &
When you first set up a brand new MySQL the logon user is root and the password is set blank.
So in the above batch file set the port number you wish to use and leave the password line blank for now.
When you run this batch file from within the mysql folder it will run the MySQL server and wait until you press a key to shut it down correctly.
Note: It is important to shutdown your SQL server correctly and not just by killing it as a task (as some DayZ scripts tend to do) as it can corrupt the database tables. This script uses the correct mysqladmin command to do so.
You'll notice I've added two almost identical task starting lines.
The 2nd one with the REM at the start will launch MySQL with a separate console window so you can see error messages etc. if you think you are having problems with MySQL. Just unREM the 2nd line and REM the 1st.
To see/edit/alter the contents of a MySQL database you need a Viewer or 'workbench'.
I use the free HeidiSQL program.
http://www.heidisql.com/
Install that.
You should be able to log onto your blank MySQL server by running the START_MYSQL and then running HeidiSQL and choose
Network type: MySQL (TCP/IP)
Hostname/IP: 127.0.0.1
Port: 3306 (unless you used a different one)
User: root
password: <nothing for now!>
Click on Open
Click on Yes to save modifications.
And you should see a blank default MySQL database with 4 blank databases in it. Ignore these.
Create a database called 'hivemind' by right clicking on the top name in the list in the left pane and choose 'create new>database'.
Then from your Sahrani server files you've no doubt already got, use the HeidiSQL 'tools> Load SQL file' option and load the 'database.sql' file. This is the default blank Sahrani database.
Once it is loaded, you need to 'execute SQL'. This creates the database. Look for the black right triangle icon in the HeidiSQL toolbar.
Hopefully all is ok and if you doubleclick on the hivemind database name in the left pane you'll see lots of Sahrani tables ready to be used.
For example click on hivemind>object_spawns and then in the right pane, click on 'data' and you should see a big pile of vehicle data in green.
Tip: To edit any item in the database, you double click on a field, edit it and then press Ctrl-Enter to actually put it into the database. You'll see the field with a red corner until it is correctly saved. This is a safety feature.
Once you're happy with a running MySQL server you can use think about changing the default blank password for root to something more secure.
To change it, right click on Tools within Heidi toolbar and choose User Manager.
Select the root user for 127.0.0.1 and reset the password to a nice complex one.
Do the same for the root user under 'localhost'.
Don't forget to alter the START_MYSQL.bat file line "set mysqlpassw=" as well of course. Tip: Don't put a space between the = and your new password.
By default the global privileges for root is set to ticked in Heidi. Leave them on unless you know better.
You can now add a user called '
dayz' from Host localhost (I assume the database is running on the same computer as the dayz server will be, if not change the IP address you enter here) and enter a different password. This will be used by the DayZ server its self to log on use and alter your SQL hivemind database.
Note: You should alter the Global privileges by turning a few things off. Just in case you get a Hacker.
I turn off: SHOW DATABASES, CREATE USER, SHUTDOWN, etc.
(But to begin with, you don't really have to.)
Now save.
There you're done.
MySQL can be run and stopped by the batch file.
Extra:
You can use HeidiSQL to check your SQL database for errors, etc. by using the Tools>Maintence option.
Ensure only hivemind is ticked in the Table tools window.
I use
Operation: Optimize every week to tidy it up.
And
Operation Check or
Analyze and
Repair if required.
You can automate these via more batch scripts if needed of course.
Typically example auto-check and repair:
Code:
@ECHO OFF
CLS
tasklist /FI "IMAGENAME eq mysqld.exe" 2>NUL | find /I /N "mysqld">NUL
if "%ERRORLEVEL%"=="1" (
@start bin\mysqld.exe --defaults-file=my-dayz.ini & echo "Please wait...Loading" & ping -n 8 127.0.0.1>nul
)
set mysqlport=3306
set mysqlpassword=<whatever>
ECHO Testing MYSQL database....
ECHO.
MYSQLcheck -u root -p%mysqlpassword% --port=%mysqlport% -A
ECHO.
ECHO.
ECHO Press any key to repair (if required)
PAUSE
MYSQLcheck -u root -p%mysqlpassword% -A --auto-repair --port=%mysqlport% --optimize
ECHO.
ECHO.
ECHO.
ECHO Retesting database after repair...
ECHO.
MYSQLcheck -u root -p%mysqlpassword% --port=%mysqlport% -A
PAUSE
You'll need to look at this window to confirm there were no serious errors.
Hope this helps people.
If I've made a mistake, please excuse, I'm only a poor human...