Spring Boot 3.2.2
mysql Ver 8.3.0
Docker version 24.0.5
gradle-8.8
flyway-9.22.3
lombok-1.18.30
brew install mysql
brew services start mysql
sudo mysql
mysql> CREATE USER <username>@'%' IDENTIFIED BY <password>;
mysql> GRANT ALL PRIVILEGES ON * . * TO 'nazran'@'%';
- Login with previous username & password
sudo mysql -u nazran -p
mysql> CREATE DATABASE wsd;
- Update the
application.yml
credentials
url: jdbc:mysql://localhost:3306/wsd?trustServerCertificate=true;
username: <username>
password: <password>
- Check
http://localhost:1991/swagger-ui/index.html
on browser if the application started properly - the wish list of a customer:
/customer-wish/list?page=1&size=10&customerId=18
- the total sale amount of the current day:
/product/sale-day
- the max sale day of a certain time range:
/product/max-sale-day?start=2024-06-01&end=2024-06-30
- top 5 selling items of all time (based on total sale amount):
/product/top-items
- top 5 selling items of the last month (based on number of sales):
/product/last-month-top-items
sudo docker pull mysql/mysql-server:latest
sudo docker images
sudo docker run --name=[container_name] -d mysql/mysql-server:latest
docker ps
sudo apt-get install mysql-client
sudo docker logs [container_name]
- [Entrypoint] GENERATED ROOT PASSWORD: which will be needed
sudo docker exec -it [container_name] bash
mysql -u root -p
- Then provide the auto generated password to login and after change the password
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '[newpassword]';
mysql> CREATE DATABASE wsd;
- Update the
docker-compose.yml
credentials with[container_name]
mysqldb:
image: [container_name]
restart: always
ports:
- 3306:3306
networks:
- springapimysql-net
environment:
MYSQL_DATABASE: wsd
MYSQL_USER: <username>
MYSQL_PASSWORD: <password>
MYSQL_ROOT_PASSWORD: <password>
docker-compose up