You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Please help us improve and share your feedback! If you find better tutorials or links, please share them
6
6
> by [opening a pull request](https://github.com/HackYourFuture/databases/pulls).
7
7
8
-
# Module #6 - Databases: Store and retrieve data with MySQL (Backend)
8
+
# Module #6 - Databases: Store and retrieve data with PostgreSQL (Backend)
9
9
10
10

11
11
12
12
Have you ever thought about how your brain remembers things? It happens automatically for humans, but that's not the case for computers. Any time you go to a website and fill in some details in a form for example, that information needs to be saved somewhere. This "somewhere" is called a `database`.
13
13
14
14
In this module, you learn all about a fundamental part of any software application: how to (safely) store data, so that it can be used on-demand. You will learn how to structure and group data so that your apps know where to find and store the correct data.
15
15
16
-
## Before you start
17
-
18
-
**Before** your first session, you need to install the necessary software: MySQL. This differs depending on your operating system.
19
-
20
-
During the installation of MySQL v8, in one of the last steps, you must configure the password encryption. Here is [a screenshot of the step](./assets/MySQL-security-setup.jpg). **You must select _Legacy_ for all the given scripts to be able to connect.**
21
-
22
-
- For Windows, download the [MySQL Community Server](https://dev.mysql.com/downloads/mysql/);
23
-
- For Linux (Ubuntu), watch the following;
24
-
video: [MySQL Installation on Linux (Ubuntu)](https://www.youtube.com/watch?v=Y_LibBhOGOY)
25
-
- For MacOS, watch the following video: [Installing MySQL on MacOS](https://www.youtube.com/watch?v=HxCXyxFEA0s).
26
-
27
-
### Setup your first database
28
-
29
-
In this document, you find all the instructions on how to setup your first database. Most of the commands are done in the command line, so make sure you have yours open before you start.
30
-
31
-
**Step 1: Logging in with the `root` user**
32
-
33
-
To get started with your new MySQL client, we first have to login with the `root` user.
34
-
35
-
> A root user, also known as a `superuser` is a special user account that has access to all commands and files of any
36
-
> particular software.
37
-
38
-
In Windows OS, if you click on the Start menu and type `MySQL Command line Client`, then the MySQL Command Line Client gives you a `msql>` prompt after typing in your root password. Note that this password is the one you used for the `root user` of the MySQL during the installation. Linux and MAC users can execute `mysql -uroot -p` and then type your root password.
39
-
40
-
**Step 2: Creating a `hyfuser` account**
41
-
42
-
After loggin in with the root user, it's time to create the account that you will use for this module. Execute the following commands, one after the other:
43
-
44
-
```bash
45
-
# Step 1: This command creates a user 'hyfuser' with password 'hyfpassword' for the database server at 'localhost'
46
-
47
-
mysql> create user 'hyfuser'@'localhost' identified with mysql_native_password by 'hyfpassword';
48
-
49
-
# If this does not work try the alternative command:
50
-
51
-
mysql> create user 'hyfuser'@'localhost' identified by 'hyfpassword';
52
-
53
-
# Step 2: This command gives all permissions to user 'hyfuser'. The (*.*) means every table of every database.
54
-
55
-
mysql> grant all privileges on *.* to 'hyfuser'@'localhost';
56
-
57
-
# Step 3: This command flushes all privileges so that mysql reloads the grant table and our changes are enabled
58
-
59
-
msyql> flush privileges;
60
-
61
-
# Step 4: This command creates a database named 'userdb'
62
-
63
-
mysql> create database userdb;
64
-
```
65
-
66
-
**Step 3: Installing MySQL driver to use with Node.js**
67
-
68
-
We want to use MySQL with JavaScript and to this end, we use the following [package](https://github.com/mysqljs/mysql). You can create a project wherever you want and install it. To test that everything is working, you can use the `connection-test.js` file. If you run it it should output `The solution is: 2`.
69
-
70
16
## Learning goals
71
17
72
18
In this module, you get familiar with the complexity of storing data. By the end of it, you have learned:
@@ -75,7 +21,7 @@ In this module, you get familiar with the complexity of storing data. By the end
75
21
- How to work with `Structured Query Language` (SQL);
76
22
- All about the `relational model`;
77
23
- How to recognise the `basic setup of a database`;
78
-
- Know about `MySQL` as an example of a relational database system;
24
+
- Know about `PostgreSQL` as an example of a relational database system;
79
25
- Know `NoSQL` databases, with an emphasis on `MongoDB`.
0 commit comments