Install MySQL Server
1. Install MySQL server:
Following are the steps for the process to install mySQL server on REDHAT7:
Note: In case you use a Mac OS. Follow the instruction in this link https://vladster.net/en/instructions/install-mysql-mac/
Step 1: Installing MySQL
$ wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
$ sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
Install mySQL server using the added MySQL yum reporsitories
$ sudo yum install mysql-server
Step 2: Starting MySQL server:
sudo systemctl start mysqld
sudo systemctl status mysqld
Note if the server has successfully started, your final line should look like this:
Nov 06 11:34:15 wisamdev57 systemd[1]: Started MySQL Server.
Step 3: Configure MySQL
Get the temporary password created during the installation:
$ sudo grep 'temporary password' /var/log/mysqld.log
Get the script to change the default password:
$ sudo mysql_secure_installation
Enter the default password that you retrieved from mysqld.log file. Then enter the new password.
Output
Estimated strength of the password: 100 Change the password for root ? (Press y|Y for Yes, any other key for No) :
Enter No because you have already changed the root password.
Step 4: Test MySQL
$ mysqladmin -u root -p version
Enter the new password
Enter password:
mysqladmin Ver 8.42 Distrib 5.7.24, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.7.24
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 5 min 14 sec
Threads: 1 Questions: 11 Slow queries: 0 Opens: 113 Flush tables: 1 Open tables: 106 Queries per second avg: 0.035
This means that your installation has been successful.
2. Create user and database:
a. Create user 'mkaroune':
a.1. Login to MySQL as root:
~> mysql -u root -p
Enter password:
a.2. Type the following command: user: mkaroune password: Mkaroune@77
mysql> GRANT ALL PRIVILEGES ON *.* TO 'mkaroune'@'localhost' IDENTIFIED BY 'Mkaroune@77';
then quit the mysql command
mysql> \q
Bye
a.3. Log to MySQL as mkaroune user and enter the created password
then quit the mysql command
~> mysql -u mkaroune -p
Enter password:
b. Create jeutrollDB databae
mysql> CREATE DATABASE jeutrollDB;
3. Configure database properties in Spring project:
Add these properties to application.properties file under the directory Jeutroll/src/main/resources/
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/jeutrollDB
spring.datasource.username=mkaroune
spring.datasource.password=Mkaroune@77
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql = true
spring.thymeleaf.cache=false
Add a comment