• 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 Let's get started with SQL! (MySQL)

splifus

New Member
Joined
Oct 18, 2007
Messages
122
Reaction score
3
Location
Canada
Hello everyone, first of all I would like to say this tutorial come from tibiafans and I decided to post it here because this tutorial helped me to start with MySql and I see alot of people asking for help.

This tutorial been made by: Black Swordsman

So here we go
---------------------------------------------------------------------------------------------------------------------------------------------------

This will (hopefully) be an all-around tutorial on setting up and using SQL servers, especially ones running on MySQL.

Part 1 - finding a good server to use
Of course, the most important thing to do is to figure out which SQL server to use.
If you don't have a quality source editor available, I suggest that you use The Forgotten Server [TFS]. Currently, the two newest versions of TFS can be found in the OT Files section here at Tibiafans.
Otherwise, I suggest using a new version of the official Open-Tibia server. This promises to be up-to-date with features and bugfixes, plus it lacks some stupid codes that other servers (known as "distros") do have. It's likely to be the least laggy and most stable that it can be. You can download the newest SVN (from the last day) through Khaos' nightly build system, which you can find in a stickied thread in Unverified OT Files.
Of course, you really should decide for yourselves. There are quite a few distros out there besides TFS, if you're willing to look. Some may suit your needs better than TFS or clean SVN.

Part 2 - Getting a MySQL server
ow, we need to get a mysql server. You could just get a mysql server without being a part of a package at the official mysql page (here), or you can download it as part of a package. I suggest downloading it as part of a package, and the particular package I suggest is xampp. Xampp can be downloaded from xampp's sourceforge page (Windows/Linux).
When installing xampp, install apache, filezilla, and mysql as a service.

(xampp users)Part 3 - Using phpmyadmin to upload your database
1) Go to: http://localhost/phpmyadmin in your web browser.
2) Find where it says "Create new database".(Image)
3) Enter the name of your database and press "Create".
4) You'll be taken to a new page where it says "database [name] was created". At the top of the page, there are a bunch of buttons. Find the one that says "import" and click it.(Image)
5) You'll be taken to another new page that gives you the option to import from a text file.
If your server is from like half a year ago, that text file would be the database.sql (forgottenserver.sql) in your OTServ's root folder (containing the otserv executable and your data folder). Otherwise it will be "schema.mysql".
Find that file using the "Browse..." button and then click the "Go" button.(Image)
6) The next page will indicate you of any or of success. Now that you've gotten the database up, you can use your SQL AAC to create new characters. Of course, you may want to tweak your OTServ database first.

Part 4 - Editting your OTServ's database
After creating your database, it can be selected from the drop-down list on the left side (it's got a different background from the main page). Do so, and you'll be brought to a new page.
On the left side, you can select which *table you wish to edit. Let's start with 'groups' (not in evo~ or older servers), as both accounts and players rely on that now. What we want to do is *insert a new *row into this *table. You can do this by clicking the "insert" button (up near where the "import" button was for the last part).
4.1 - Groups
For starters, you need to understand what a Group is. By the name, you can gather that it's some sort of 'collective entity' (or group :p, in simple english). In the case of OTServ, players and accounts belong to a specific group in order to have special powers. Groups are basically the new way of doing GMs and GODs, instead of just access=3 or access=5.
Groups have 6 *fields.
  • The first, "id", is pretty self-explanatory: it's a number used to identify the group from other groups. Each "id" needs to be unique, you cannot have two groups with the same "id".
  • The second, "name", isn't really used. It's mostly to tell them apart, I think.
  • The third, "flags", is probably the most important part. Flags control almost everything. There are flags for players to not be attacked, not be able to attack, not be able to attack players, not be able to be banned, etc. These are completely seperate from access levels, so you can safely protect a group of players from having to deal with monsters without needing to give them a high enough access to use commands; or possibly to be able to have a character who can use commands but aside for that is just a regular player (say, a secondary character for your GOD). The means of finding out what to set this number to is pretty complicated, so blackknight from OTF made a tool to do it for you: http://hem.bredband.net/johannesrosen/playerflags.html
  • The fourth, "access", is the same as it's always been. You need a certain access to use certain commands.
  • The fifth, "maxdepotitems", is self-explanatory. This number specifies how many items a player can have in his depot. It's nice for GMs to be able to hold more items, etc.
  • The sixth, "maxviplist", is also self-explanatory. This number specifies how many players a player can have on his VIP. It's nice for GMs to have alot of players on his VIP. :p

Now that you've learned all that, go ahead and make your groups. I suggest 0 access and 0 flags for normal players!
Just fill the fields and click the "Go" button.
4.2 Accounts
Now that we have our groups configured, let's make ourselves a GOD account since we're hosting the server and everything. Let's start by clicking 'accounts' on the left side, and clicking the 'insert' button; just like we did for 'groups'. Now, let's see what fields that account has:

  • id - this is the account's account number. don't ask me why they chose to call it 'id' instead.
  • password - speaks for itself. this is the account's password
  • group_id - this is the id of the group we want to set it to. This is why we needed to create our groups before our accounts. Setting this should only affect the # of people on your VIP, though it may affect other things.
  • email - speaks for itself. This is the email to be associated with the account. It's not used in OTServ source, but you can use it on your AAC to add email verification and prevent creation of multiple accounts.
  • blocked - set to 1 to block an account, set to 0 to unblock it. No idea if it actually does anything yet.
Just fill in the fields as you want and hit 'Go' again. Next, we're going to create our account's players. :)

-- continued in next post --
 
Last edited:
4.3 Players
Well, now it's time to go do with players as we've done with accounts and groups before.
You'll notice that players have many more fields than accounts and groups do. This is because players store much more information. You'll also notice skills and items are not in here - that's fine, they have their own tables. Player's skills are all set to 10 whenever you make a new player, so you don't need to worry about those either. The player's fields are as follows:

  • id - used to identify the player. it's used by every table that references players; including bans**.
  • name - the player's name. Its use should be very obvious.
  • account_id - the 'id' of the account it belongs to. used in loading accounts, so make sure its right.
  • group_id - the 'id' of the group it belongs to. be careful when making new players, that they use the right group.
  • premend - this is when your premium runs up.
  • sex - the gender of your character. 0 is male, 1 is female; or maybe it's the other way around vocation - the player's vocation. the number should match with the numbers you have in your server's vocations.xml
  • experience - the player's experience points.
  • level - the player's level
  • maglevel - the player's magic level
  • health - the player's current health
  • healthmax - the player's maximum health
  • mana - the player's current mana
  • manamax - the player's maximum mana
  • manaspent - the amount of mana used on spells (for advancing ml)
  • soul - amount of soul points a player has
  • direction - direction the player is facing. just set to a number between 1 and 4, it really doesn't matter does it? :p
  • lookbody - the color of the player's torso ('primary')
  • lookfeet - the color of the player's feet ('detail')
  • lookhead - the color of the player's head
  • looklegs - the color of the player's legs ('secondary')
  • looktype - the player's outfit (128 = male, 136 = female [I think])
  • lookaddons - the player's set addons. 1 = first, 2 = second, 3 = first and second
  • posx - the x coordinates of the player's position**
  • posy - the y coordinates of the player's position**
  • posz - the z coordinates of the player's position**
  • cap - the player's maximum capacity
  • lastlogin - the last time the player logged in. set to 0.
  • lastip - the last IP the player logged in on. set to 0.
  • save - just whether or not to save the player. 1=save, 0=dont. Nice for test characters.
  • conditions - leave alone
  • redskulltime - how long the player has redskull for. set to 0
  • redskull - whether or not player has a redskull. 0=no, 1=yes.
  • guildnick - player's nickname in his guild.
  • rank_id - player's rank in his guild.
  • town_id - id of player's town. NOTE: used to set his temple position. be sure to set your temples for each town!
  • loss_experience - the % of experience to lose when dying. 10 is normal tibia's.
  • loss_mana - the % of manaspent to lose when dying. 10 is normal tibia's.
  • loss_skills - the % of skillpoints to lose when dying. 10 is normal tibia's.

Fill out the fields as you please, keeping my notes in mind. Now you have a character and an account set. This is all you need to know to host a mysql server well!

Part 5 - Websites & AACs
The most important part of your server is the means by which you create accounts. Afterall, nobody wants to play a server where they can't have their own account unless it's some form of war server. Some servers have in-game account creators that many players love to use for their simplicity, but unfortunately these are often prone to bugs and really shouldn't be used. Website AAC [Automated Account Creators] are usually the best option. In the case of a serious server, it's usually a good idea to build your own; but unfortunately that's really outside the scope of this tutorial. Instead, I'll introduce you to various website AACs that use MySQL.
5.1 OpenTibia Server Content Management System [OTSCMS]
OTSCMS is the highly advanced website AAC created by official OTServ developer Wrzasq. It's updated quite regularly; and beyond the basic features that most AACs have, OTSCMS also sports its own built-in forum. I've never before used, so I can't help you with much besides a download link. Here's the most recent version, complete with a windows installer: http://sourceforge.net/project/downloading.php?groupname=otscms&filename=otscms-3.0.5-easy.tar.bz2&use_mirror=easynews
5.2 Avarians Forgotten AAC
******/OTLand user Avarian has created an AAC for TFS. It can be found on ****** and OTLand(site is down so I can't provide you a link).
Sorry for the off-site links, but I'm too lazy to repost it here.
5.3 Nicaw SQL
****** user Nicaw has been creating his AAC for quite some time, and it is very well known. The thread can be found on ******, again I'm too lazy to repost. The thread even contains a version meant for use with Evolutions, for those of you who refuse to update.

Those are all the AACs I could find.

* - SQL jargon. You'll be seeing alot of it. Essentially, a table is a specific type of information. A row is a piece of that specific type of information, and when you insert it into that table, you're just identifying it as being that specific piece of information to find it quickly later on. A field is information the table contains.
** - not the case for evolutions and most 7.6 servers. The main reason they suck.

-------------------------------------------------------------------------------------------------------------------------------------------------

I suggest to use Gesior Account Manager..You can find it here.

I hope its will help you like its helped me.


Timax25~
 
Last edited:
You gotta run Xammp and run Apache and MySql.

Give me 5 min I'll upload a picture

Edit:

When you install xammp(image)

When you run xammp you press Start on Apache and MySql (image) its should like like this after (image) or its should alrdy run when you start XAMMP control panel


I hope its help you.
 
Last edited:
Maybe you should reinstall Xammp cuz I dont see why its dont work..for me Apache and MySql work.
 
Now when i re-installed it sayd that port 80 and 400~ somthing allready was in use.. (no they are not :p).. idk what i should do now then, im not using those ports.
 
I've done that all as you said, just didnt make AAC cuz i have acc manager on my server and when i start distro, its still not working tho it says "Forgotten Server has become online!"

I think there is a problem with ports, do i need to change port 3306 to 7171 in mysql?

HELP ME PLX xD!:(:(:(
 
When I am starting up the server its says that it cannot to database, what shall I do?
 
Sql its a bit hard in beginning i had it not easy me either but now i can it ;D it's quite easy when you can it. :D
 
i have three questions

no one can log into acc manager except me what do i do?

how do i make my char admin?

how to i put a downloaded map onto my server?
 
You don't need to reinstall anything, Teh problem is you are using some programms which are using same ports as ur apache.
well the one of them may be "skype" also shut down all programms which are beeing running and then start xampp from new ^.-

Should also work.
 
Back
Top