eAthena SQL Installation and Upgrade Instructions

1 Installation
  1.1 Windows
  1.2 Linux
  1.3 FreeBSD
2 Upgrading
  2.1 Upgrading from version 817
  2.2 Upgrading from version 0.5.2
  2.3 Upgrading from version 1.0 RC 1
3 Mail System
  3.1 Adding the mail database
  3.2 Activating the mail system

1 Installation
==============

1.1 Windows
-----------

1. It is not the aim of this document to explain the installation, concepts or usage of MySQL. If you are unfamiliar with MySQL, familiarise yourself with it and read at least these sections of the MySQL reference manual (http://dev.mysql.com/doc/mysql/en/index.html):

- 2.2.1 Installing MySQL on Windows
- 2.4   Post-Installation Setup and Testing
- 5.4   General Security Issues
- 5.5   The MySQL Access Privilege System
- 5.6   MySQL User Account Management

2. If fast and secure access to a MySQL server is unavailable, install, start and configure MySQL database server version 4.0.x. If you are using a version of Windows which is a member of the NT family, we recommend that you install MySQL as a service.

3. Create a new database and a new user account with only SELECT, INSERT, UPDATE and DELETE privileges on the database. For example:

CREATE DATABASE ragnarok;
GRANT
    SELECT,INSERT,UPDATE,DELETE
    ON `ragnarok`.*             # database
    TO 'ragnarok'@'localhost'   # username@address
    IDENTIFIED BY 'password';   # password

For security, do not use the password "password" for your user account.

4. Execute the batch queries stored in sql\main.sql. If you want your item and monster databases stored in your MySQL database, execute sql\database.sql too. For example:

mysql -D ragnarok -h localhost -u root -p < sql/main.sql | more && mysql -D ragnarok -h localhost -u root -p < sql/database.sql | more

5. Add an inter-server account for every character server you intend to link to your login server. For example:

USE ragnarok
INSERT INTO `login`
    (`userid`,`user_pass`,`sex`,`email`)
    VALUES ('inter-server_chaos','password','S','');

Every character server linked to your login server requires its own inter-server account; inter-server accounts are used by the servers to communicate with each other. The differences between user and inter-server accounts are:

- The "sex" field value must equal "S"
- The "e-mail" field value is unused and therefore should be set to ""
- The "level", "error_message", "connect_until", "memo", "ban_until" and "state" field values are unsued and therefore should be set to 0

Anyone who knows the username and password of an inter-server account can control a character server using that account. Therefore, choose secure passwords for your inter-server accounts.

6. Add accounts or convert existing accounts from a text file database.

To add new accounts, use, for example:

USE ragnarok
INSERT INTO `login`
    (`userid`,`user_pass`,`sex`,`email`,`level`)
    VALUES ('<username>','<password>','<gender>','<e-mail address>',<game master level>);

Where <gender> is either M, F, or S for male, female, and inter-server respectively and <e-mail address> is the e-mail address (for confirmation of character deletion).

To convert existing accounts stored in a text file database, use login-converter.exe and char-converter.exe. Parties and guilds cannot be converted.

7. Edit the configuration files in conf\ (except import\, mapflag\, help.txt, water.txt and water_height.txt) according to your computer configuration, network configuration, MySQL database server configuration and personal preferences.

8. Download the latest cygwin1-yyyymmdd.dll.bz2 snapshot, where "yyyymmdd" is the build date, from http://cygwin.com/snapshots/. Extract cygwin1-yyyymmdd.dll from the archive, rename it to cygwin1.dll, and move it to your system or system32 directory -- depending on your version of Windows -- in your system root directory.

9. Optionally compile:

a. Install Cygwin with these packages:

devel/
  gcc,
  gcc-g++,
  gcc-mingw-core,
  gcc-mingw-g++,
  make,
  mingw-runtime,
  mktemp

b. Using Cygwin, install the MySQL libraries by compiling and installing the MySQL database server source distribution for Linux with "./configure --without-server && make && make install".

c. Using Cygwin, enter "make" in the eAthena SQL directory. Recompile with "make clean && make".

1.2 Linux
---------

1. It is not the aim of this document to explain the installation, concepts or usage of MySQL. If you are unfamiliar with MySQL, familiarise yourself with it and read at least these sections of the MySQL reference manual (http://dev.mysql.com/doc/mysql/en/index.html):

- 2.2.2 Installing MySQL on Linux
- 2.4   Post-Installation Setup and Testing
- 5.4   General Security Issues
- 5.5   The MySQL Access Privilege System
- 5.6   MySQL User Account Management

2. If fast and secure access to a MySQL server is unavailable, install, start and configure MySQL database server version 4.0.x. If you are using a version of Windows which is a member of the NT family, we recommend that you install MySQL as a service.

3. Create a new database and a new user account with only SELECT, INSERT, UPDATE and DELETE privileges on the database. For example:

CREATE DATABASE ragnarok;
GRANT
    SELECT,INSERT,UPDATE,DELETE
    ON `ragnarok`.*             # database
    TO 'ragnarok'@'localhost'   # username@address
    IDENTIFIED BY 'password';   # password

For security, do not use the password "password" for your user account.

4. Execute the batch queries stored in sql/main.sql. If you want your item and monster databases stored in your MySQL database, execute sql/database.sql too. For example:

mysql -D ragnarok -h localhost -u root -p < sql/main.sql | more && mysql -D ragnarok -h localhost -u root -p < sql/database.sql | more

5. Add an inter-server account for every character server you intend to link to your login server. For example:

USE ragnarok
INSERT INTO `login`
    (`userid`,`user_pass`,`sex`,`email`)
    VALUES ('inter-server_chaos','password','S','');

Every character server linked to your login server requires its own inter-server account; inter-server accounts are used by the servers to communicate with each other. The differences between user and inter-server accounts are:

- The "sex" field value must equal "S"
- The "e-mail" field value is unused and therefore should be set to ""
- The "level", "error_message", "connect_until", "memo", "ban_until" and "state" field values are unsued and therefore should be set to 0

Anyone who knows the username and password of an inter-server account can control a character server using that account. Therefore, choose secure passwords for your inter-server accounts.

6. Add accounts or convert existing accounts from a text file database.

To add new accounts, use, for example:

USE ragnarok
INSERT INTO `login`
    (`userid`,`user_pass`,`sex`,`email`,`level`)
    VALUES ('<username>','<password>','<gender>','<e-mail address>',<game master level>);

Where <gender> is either M, F, or S for male, female, and inter-server respectively and <e-mail address> is the e-mail address (for confirmation of character deletion).

To convert existing accounts stored in a text file database, use login-converter and char-converter. Parties and guilds cannot be converted.

7. Edit the configuration files in conf/ (except import/, mapflag/, help.txt, water.txt and water_height.txt) according to your computer configuration, network configuration, MySQL database server configuration and personal preferences.

8. Compile with "make". Recompile with "make clean && make".

1.3 FreeBSD
-----------

1. It is not the aim of this document to explain the installation, concepts or usage of MySQL. If you are unfamiliar with MySQL, familiarise yourself with it and read at least these sections of the MySQL reference manual (http://dev.mysql.com/doc/mysql/en/index.html):

- 2.2.5 Installing MySQL on Other Unix-Like Systems
- 2.4   Post-Installation Setup and Testing
- 5.4   General Security Issues
- 5.5   The MySQL Access Privilege System
- 5.6   MySQL User Account Management

2. If fast and secure access to a MySQL server is unavailable, install, start and configure MySQL database server version 4.0.x. If you are using a version of Windows which is a member of the NT family, we recommend that you install MySQL as a service.

3. Create a new database and a new user account with only SELECT, INSERT, UPDATE and DELETE privileges on the database. For example:

CREATE DATABASE ragnarok;
GRANT
    SELECT,INSERT,UPDATE,DELETE
    ON `ragnarok`.*             # database
    TO 'ragnarok'@'localhost'   # username@address
    IDENTIFIED BY 'password';   # password

For security, do not use the password "password" for your user account.

4. Execute the batch queries stored in sql/main.sql. If you want your item and monster databases stored in your MySQL database, execute sql/database.sql too. For example:

mysql -D ragnarok -h localhost -u root -p < sql/main.sql | more && mysql -D ragnarok -h localhost -u root -p < sql/database.sql | more

5. Add an inter-server account for every character server you intend to link to your login server. For example:

USE ragnarok
INSERT INTO `login`
    (`userid`,`user_pass`,`sex`,`email`)
    VALUES ('inter-server_chaos','password','S','');

Every character server linked to your login server requires its own inter-server account; inter-server accounts are used by the servers to communicate with each other. The differences between user and inter-server accounts are:

- The "sex" field value must equal "S"
- The "e-mail" field value is unused and therefore should be set to ""
- The "level", "error_message", "connect_until", "memo", "ban_until" and "state" field values are unsued and therefore should be set to 0

Anyone who knows the username and password of an inter-server account can control a character server using that account. Therefore, choose secure passwords for your inter-server accounts.

6. Add accounts or convert existing accounts from a text file database.

To add new accounts, use, for example:

USE ragnarok
INSERT INTO `login`
    (`userid`,`user_pass`,`sex`,`email`,`level`)
    VALUES ('<username>','<password>','<gender>','<e-mail address>',<game master level>);

Where <gender> is either M, F, or S for male, female, and inter-server respectively and <e-mail address> is the e-mail address (for confirmation of character deletion).

To convert existing accounts stored in a text file database, use login-converter and char-converter. Parties and guilds cannot be converted.

7. Edit the configuration files in conf/ (except import/, mapflag/, help.txt, water.txt and water_height.txt) according to your computer configuration, network configuration, MySQL database server configuration and personal preferences.

8. Compile with "gmake". Recompile with "gmake clean && gmake".


2 Upgrading
===========

2.1 Upgrading from version 817
------------------------------

1. Execute the batch queries stored in sql/upgrade_817.sql and sql/upgrade_0.5.2_main.sql.

2. If you want your item and monster databases stored in your MySQL database, execute the batch queries stored in sql/database.sql.

2.2 Upgrading from version 0.5.2
--------------------------------

1. Execute the batch queries stored in sql/upgrade_0.5.2_main.sql.

2. If you created the item_db and mob_db tables, execute the batch queries stored in sql/upgrade_0.5.2_database.sql.

2.3 Upgrading from version 1.0 RC 1
-----------------------------------

1. Execute the batch queries stored in sql/upgrade_1.0.0-rc1_main.sql.


3 Mail System
=============

2.1 Adding the mail database
----------------------------
1. Execute the batch queries stored in sql/mail.sql

2. Set mail_system option in conf/battle_athena.conf to 1 or yes.
