Python-Ref > Databases and Python > Python and MySQL > Setting up the test data

Klíčová slova
Knihovní funkce

Setting up the test data

How to prepare a database that will be used in following examples.
The examples on following pages will use the world database that is distributed by MySQL. The only change made to the original file was transcoding to UTF-8 and change of the table charsets to UTF-8. The copy of the exact version we use is here, the original can be found and downloaded here.
To setup the database the first time, the following steps need to be followed.
  1. enter MySQL command line as root or another privileged user:
    >> mysql -u root -p
  2. create the database:
    mysql> CREATE DATABASE world;
  3. create the user we will use:
    mysql> GRANT ALL ON world.* TO test@localhost IDENTIFIED BY "pass123";
  4. exit MySQL command line
To fill or restore the database when necessary, the following steps need to be done.
  1. Unzip the source file to obtain world.sql
  2. Run:
    mysql -u test -p world < world.sql
    and enter the password ("pass123" if you have followed the above steps) to fill the database.