<In the last post I spoke about my decision to start using MySql , now I will speak about how to set up a simple test database using the command line prompt>
CONNECTING TO THE SERVER
MySql has a basic tool to set up (almost) everything you need from your SQL server.
After installing MySql you just need to use the command:
That will connect to the mysql server with ServerIp, and try to validate,
if you don't write the IP it will default to localhost, the username is
the username used to login into the server, and finally -p makes mysql
to ask for the password of the username:
Here we are, logged in..
CREATING DATABASES AND TABLES
Next step would be very simple, create our database:
Notice the semicolon ";", every instruction in the mysql command prompt must finish with ";", it's the end of sentence command
It will create a new database "rpgdata" , then we can check the databases in our server:
We can delete the databases with the command:
After creating a database and before we can actually work with it we need to "use" it with the command:
Next step would be creating the tables to store the data:
Now we can check the tables we have in our database:
And another interesting thing: we can check the database structure with the command:
At this point, we can start using standard SQL sentences to handle the data:
A pair of examples:
SQL Language is almost a programming language itself so it's way beyond my hand to teach the language, anyway I will explain the sentences when I use them so you don't have to worry about it.
BACKUPS AND RESTORES
Finally, to make a backup from a database to a plain text file and restore it later we have two commands:
To make a backup from a database to a file...
To restore a database from a backup file
<Notice that in both commands you have to execute the commands from the terminal window, not from the mysql prompt>
And that's all for now, that's all we are going to need to start using the mysql server, creating our database and the tables inside, we can now design our game database, and we could even insert the desired data inside (I Wont recommend that!), but instead we are going to use c++ to connect to the mysql server and launch SQL sentences...
In the next post: Using mysql from c++ + code::blocks.