Installing the MySQL server

As mentioned previously, we will install the MySQL server in the same EC2 instance. You can also use an RDS instance from AWS, which is what Amazon recommends for MySQL databases. RDS has many advantages, but to keep things short, we will install MySQL in the same VM instance. Make sure that a shell is open on the instance, as explained earlier, and execute the following commands:

Commands

Description

sudo yum install mysql-server -y

Installs MySQL

sudo chkconfig mysqld on

Activates the MySQL service

sudo service mysqld start

Starts the MySQL service

mysqladmin -u root password [your_new_pwd]

Sets the password

mysqladmin -u root -p create course_management

Creates course_management database

create user 'eclipse-user'@'%' identified by ‘enter_password_for_new_user’

Creates a new user

 

 mysql -u root -p

Logs in to MySQL from the command line

create user 'eclipse-user'@'%' identified by ‘password_for_eclipse_user’;

Execute this at mysql> prompt to create a new user called eclipse-user

grant all privileges on *.* to 'eclipse-user'@'%' with grant option;

Grants privileges to the new user

exit

Exits the MySQL console

 

You can now connect to this instance of the MySQL server from your host machine. But before you try to connect to the server, make sure that you have set an inbound rule on the EC2 instance to allow a connection from your machine (IP) on port 3306 (see Figure 13.7). You can then either connect from the Terminal (command line) or use MySQL Workbench (see Chapter 1, Introducing JEE and Eclipse, for more information on installing MySQL Workbench). Use the public DNS name of the instance to connect.

Create tables in this database as described in Chapter 4, Creating JEE Database Applications. Alternatively, use course_management.sql, which is in the CourseManagementEAR folder in the source code for this chapter, to import the tables. In MySQL Workbench, select the Server | Data Import menu. Select Import from Self-Contained File and enter the path to course_management.sql. Select course_management as the Default Target Schema. Select Dump Structure and Data. Then, click the Start Import button.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.178.181