Install and start Redis

Redis is introduced

Redis is an open source in-memory database, Redis provides a variety of different types of data structures, many business scenarios can be naturally mapped to these data structures. In addition, features like replication, persistence, and client sharding make it easy to scale Redis into a system that can contain hundreds of gigabytes of data and handle millions of requests per second. Redis supports things like strings, hashes, lists, sets, sorted collections with scoped queries Sets, bitmaps, Hyperloglogs, geospatial indexes with radius queries and streams, etc.

Start the Redis

1. Docker starts a Redis server of version 6.0.7 named redis607. Set the version, container name, and port number as required.

Docker run --name redis607 -p 6379:6379 -d redis:6.0.7Copy the code

2. Start another REDis cli to connect to the Redis server

Docker run -it --network host --rm redis:6.0.7 redis-cliCopy the code

After the above two steps, you can start the Redisx database with Docker.

Docker start MySQL

MySQL is introduced

MySQL is widely used in small and medium-sized websites on the Internet. Because of its small size, speed, and low total cost of ownership, especially because it is open source, many companies have adopted MySQL databases to reduce costs. MySQL database can be regarded as one of the fastest SQL language databases.

MySQL > install MySQL

1. Install the mysql instance

docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 --name mysql_test -d mysql:latest
Copy the code
  • -p 3306:3306 Maps port 3306 of the Docker container to port 3306 of the host
  • -e MYSQL_ROOT_PASSWORD=123456 Set the root user’s password 123456
  • –name mysql_test Name the container instance mysql_test
  • Mysql :latest Mirror version used
  • -d Background running

2. Enter the container

docker exec -it mysql_test bash
Copy the code
  • – IT Provides an interactive environment
  • Bash After entering the instance, start the bash program

Log in to the database

mysql -uroot -p
Copy the code

4. Create a database

create database go_demo charset=utf8;
Copy the code

5. Exit the database and host

exit
Copy the code

Then control + P + Q will do it. After the above steps, you can start MySQL with Docker. MySQL > select * from user where user = ‘root’;

Mysql > create user 'rootname' identified with mysql_native_password by 'Root23456)'; Mysql > grant all PRIVILEGES on *.* to 'rootName '; // Refresh privileges flush PRIVILEGES;Copy the code