Database In Node.js

TurnToJPG -->


Install MongoDB via:

$ sudo pacman -S mongodb
$ sudo systemctl start mongodb
$ sudo systemctl enable mongodb
$ mongodb

Later I will cover this topic.


Installation of MySQL

The implementation chosen by Arch Linux is called MariaDB, install it via:

$ sudo pacman -S mariadb 

Configuration steps:

$ sudo systemctl start mysqld.service
[Trusty@~]$ sudo mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Now you can login the mariadb via:

$ mysql -u root -p
MariaDB [(none)]> SHOW DATABASES;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
3 rows in set (0.00 sec)

Node.js of MariaDB


Running result:> SET my.key test
OK> KEYS my.key
1) "my.key"> VALUES my.key
(error) ERR unknown command 'VALUES'> GET my.key
"test"> keys *
 1) ""
 2) ""
 3) ""
 4) "mykey"
 5) "rq:job:b9b76e04-8bb7-4652-83e9-4453de981554"
 6) "rq:queue:default"
 7) ""
 8) "_kombu.binding.celeryev"
 9) ""
10) ""
11) "rq:queues"
12) ""
13) "_kombu.binding.celery"
14) "my.key"
15) ""> KEYS my.key
1) "my.key"> SET online.users 0
OK> onlien.users
(error) ERR unknown command 'onlien.users'> online.users
(error) ERR unknown command 'online.users'> KEYS online.users
1) "online.users"> GET online.users
"0"> INCR online.users
(integer) 1> INCR onlien.users
(integer) 1> INCR online.users
(integer) 2> HSET profile.1 name Guillermo
(integer) 1> HGETALL profile.1
1) "name"
2) "Guillermo"> HSET profile.1 last Rauch
(integer) 1> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"> HSET profile.1 programmer 1
(integer) 1> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"
5) "programmer"
6) "1"> HDEL profile.1 programmer
(integer) 1> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"> RPSH "job 1"
(error) ERR unknown command 'RPSH'> RPUSH "job 1"
(integer) 1> HGET profile.1
(error) ERR wrong number of arguments for 'hget' command> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"> LRANGE 0 -1
1) "job 1">> RPUSH "job 2"
(integer) 2> LRANGE 0 -1
1) "job 1"
2) "job 2"> RPUSH "job 3"
(integer) 3> LRANGE 0 -1
1) "job 1"
2) "job 2"
3) "job 3"

DataSet in Redis:> SADD myset "a member"
(integer) 1> SMEMBERS myset
1) "a member"> SADD myset "a second member"
(integer) 1> SMEMEBERS myset
(error) ERR unknown command 'SMEMEBERS'> SMEMBERS myset
1) "a second member"
2) "a member"> SREM myset "a second member"
(integer) 1> SMEMBERS myset
1) "a member"