• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

MySQL How to setup a MySQL Database (screenshots included) - Last update: 16/7/2009

When I used the .s3db file, this came up..

Code:
Error
There is a chance that you may have found a bug in the SQL parser. Please examine your query closely, and check that the quotes are correct and not mis-matched. Other possible failure causes may be that you are uploading a file with binary outside of a quoted text area. You can also try your query on the MySQL command line interface. The MySQL server error output below, if there is any, may also help you in diagnosing the problem. If you still have problems or if the parser fails where the command line interface succeeds, please reduce your SQL query input to the single query that causes problems, and submit a bug report with the data chunk in the CUT section below:
----BEGIN CUT----
eNrtXW9s28YVP4p21DBD/6WpkqpZGDSOo8Z2JDl2GgdBqjhMYlSWUklO1qKBQ0uMw1oiFZFK7BQF

The "cut" section is rather long, maybe 200 lines, so I decided to post the 1st line of code only..If you need the rest, just ask. Any help is apreciated..
 
-- NOTE: IMPORTING TRIGGERS.SQL USING PHPMYADMIN WON'T WORK SO THERE'S NO NEED TO TRY THAT.

1. Create a file, lets call it triggers.sql.
-- NOTE: THERE IS ALREADY A TRIGGERS.SQL IN THE SAME DIRECTORY AS THIS FILE, YOU CAN USE IT IF YOU WANT AND JUMP TO STEP 5.
2. Open it.
3. Paste this inside it (note; change skills part if you dont want players to start with 10 in all skills):

Code:
DROP TRIGGER IF EXISTS `oncreate_players`;
DROP TRIGGER IF EXISTS `oncreate_guilds`;
DROP TRIGGER IF EXISTS `ondelete_players`;
DROP TRIGGER IF EXISTS `ondelete_guilds`;
DROP TRIGGER IF EXISTS `ondelete_accounts`;
DELIMITER |

CREATE TRIGGER `ondelete_accounts`
BEFORE DELETE
ON `accounts`
FOR EACH ROW
BEGIN
    DELETE FROM `bans` WHERE `account` = OLD.`id`;
END|

CREATE TRIGGER `ondelete_guilds`
BEFORE DELETE
ON `guilds`
FOR EACH ROW
BEGIN
    UPDATE `players` SET `guildnick` = '', `rank_id` = 0 WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = OLD.`id`);
END|

CREATE TRIGGER `ondelete_players`
BEFORE DELETE
ON `players`
FOR EACH ROW
BEGIN
    DELETE FROM `bans` WHERE `type` = 2 AND `player` = OLD.`id`;
    UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
END|

CREATE TRIGGER `oncreate_guilds`
AFTER INSERT
ON `guilds`
FOR EACH ROW
BEGIN
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('the Leader', 3, NEW.`id`);
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Vice-Leader', 2, NEW.`id`);
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Member', 1, NEW.`id`);
END|

CREATE TRIGGER `oncreate_players`
AFTER INSERT
ON `players`
FOR EACH ROW
BEGIN
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 0, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 1, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 2, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 3, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 4, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 5, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 6, 10);
END|

DELIMITER ;

4. Save the file and close it.
5. If you're using Windows then open cmd and cd to your directory with mysql.exe, if you're using Linux
then launch a terminal.
6. Linux users type: mysql -u yourUserName yourDatabaseName -p < triggers.sql
Example: mysql -u root theforgottenserver -p < triggers.sql

Windows users type: pathToMySQL -u yourUserName yourDatabaseName -p < triggers.sql
Example: C:/pathtomysql -u root theforgottenserver -p < triggers.sql

Note: You must be in the directory there triggers.sql is, to change directory use the command 'cd path'.

7. You will now be asked to type in your password for the user you picked, do it.
8. If there's no output when you done that, you're done, you can close this file, if you got any error read on.

Credits: Me and Talaturen


i sorta get lost here can you help me? and also i had to make the triggers.sql file myself i ran a search on my comp to make sure i just didnt over look it and it didnt come up so i got to set 5
 
Last edited:
Told you it's a long @$$ code...Man how long does it take to get a responce from ppl who know what's goin' on? :/
 
Told you it's a long @$$ code...Man how long does it take to get a responce from ppl who know what's goin' on? :/

you need to use the sources and the forgotten.sql file is located inside there
 
you need to use the sources and the forgotten.sql file is located inside there

http://forgottenserver.svn.sf.net/ is a broken link or the site is down for now :(
So I can't get sources...

5. If you're using Windows then open cmd and cd to your directory with mysql.exe, if you're using Linux
then launch a terminal.
6. Linux users type: mysql -u yourUserName yourDatabaseName -p < triggers.sql
Example: mysql -u root theforgottenserver -p < triggers.sql

Windows users type: pathToMySQL -u yourUserName yourDatabaseName -p < triggers.sql
Example: C:/pathtomysql -u root theforgottenserver -p < triggers.sql

Note: You must be in the directory there triggers.sql is, to change directory use the command 'cd path'.

7. You will now be asked to type in your password for the user you picked, do it.
8. If there's no output when you done that, you're done, you can close this file, if you got any error read on.


Do you think, maybe..You could make this a little more clearer. I mean..Step5, "If you're using Windows then open cmd and cd to your directory with mysql.exe" Does that mean to RUN the CMD and type in the path to MYSQL.exe? cuz that didn't do anythin'.. Some specefics would be GREATLY apreciated.... Tnx :)
 
Last edited by a moderator:
Do you think, maybe..You could make this a little more clearer. I mean..Step5, "If you're using Windows then open cmd and cd to your directory with mysql.exe" Does that mean to RUN the CMD and type in the path to MYSQL.exe? cuz that didn't do anythin'.. Some specefics would be GREATLY apreciated.... Tnx :)

Open CMD, write
Code:
C:\xampp\mysql\bin\mysql.exe -u root theforgottenserver -p < theforgottenserver.sql
(there's no triggers.sql anymore, it's included in the theforgottenserver.sql file now.) that's the default location of xampp and should make it a little clearer.
the
 
Last edited:
if there is no triggers.sql any more why were we told to make 1? and did we need to make a copy of theforgottenserver.sql into the mysql.exe folder?


btw you spelt forgotten wrong here -u root theforgottsenserver -p extra s
Code:
C:\xampp\mysql\bin\mysql.exe -u root theforgottenserver -p < theforgottenserver.sql
 
Last edited:
ok, thanks a lot i get it now this is what i had to cd to
Code:
C:\xampp\mysql\bin\mysql.exe -u root otserv -p < forgottenserver.sql
also you have to make a copy of forgottenserver.sql from the sources into the bin folder
then once i entered my password i still got an error but at least it worked

here is my error if some1 can help me:
Code:
ERROR 1050 (42S01) at line 166: Table 'player_deaths' already exists
 
Ok...now that I've added into C:\xampp\mysql\bin\mysql.exe -u -p forgotten.sql I'm lookin at a load of info hopeing I can figure out wtf I have to do next..this tutorial is turning out very long and confusing..but it's workin..so far :p

All this stuff is sayin is a bunch of true/false no default value, idk what's goin on..this is my 1st time usin sqls.. >.<
 
Last edited:
try doing this
cd C:\xampp\mysql\bin\
then do this
mysql.exe -u root theforgottenserver -p < forgottenserver.sql
then you should be asked for your password
 
ok it doesnt let me go to the xampp site to change pass it always ask for me to enter pass and username before i can get to it someone plx help me :)
 
it doesnt work for me
it says this
Code:
 SQL query:

DROP TRIGGER IF EXISTS `oncreate_players`
 
try doing this
cd C:\xampp\mysql\bin\
then do this
mysql.exe -u root theforgottenserver -p < forgottenserver.sql
then you should be asked for your password

i get to the enter password part, but when i enter the password it says: Error 1049 <42000> unknown database "blank"

And when i try putting the database name instead it says: Error 1045 <28000> Access denied for user 'root'@'localhost' <using password: YES>
 
Back
Top