Execution of $ createdb mydb suppose that the user is already logged to database manager in the cli bu psql In this tutorial they are not describing before how to connect to the database using psql or something equivalent
If they are already logged into the CLI at this point they haven't followed the tutorial. That step is covered in the following section.