From the course: Java EE: Application Servers

Install the database

From the course: Java EE: Application Servers

Start my 1-month free trial

Install the database

- [Instructor] Later on in our lessons for each of our four Java EE Application servers we'll need to have a mySQL database installed and configured. In an effort to simplify this, I provide an instructions to the practice files which attempts to lay out installation processes for Windows or Mac users. This directory lists five files. Please begin with the start_here. This file will help you decide which path to take based on whether you're using Windows or Mac. Because I'm using a Mac, we'll start with the brew_notes. Opening our brew_notes, our first task is to copy this line right here, and paste it into our terminal window. This may take a few minutes to complete. While this is installing, let me tell you about Brew and what it provides. Brew is a package management system, similar to Yum for Linux. We'll be using Brew to install our mySQL database instance. Once Brew is finished, the next task is to run brew update. After this completes, we'll run the command brew info mysql, and this command will tell us the version of mySQL that's available on the Brew system. There's 8.0. With that we'll type brew install mysql, hit enter. This may take a moment to complete based on your broadband speed. With the installation complete, we will install the Homebrew services piece which configures the system to start up some software libraries when the computer powers up. I'm going to copy this from our command over here, brew tap homebrew/services, paste that. We'll follow this command up with brew services start mysql, which will add mySQL to the startup scripts and start mySQL. Then we'll run brew services list to validate that mySQL has started. With mySQL installed, we need to set the password. This will be done in step eight of our brew notes. Step eight of our brew notes tells us to proceed to the mysql_login_details file. First command we'll run is mysql -V. This tells us the version of mySQL that's running. Next we'll type mysqladmin -u root password and then our password. Hit enter. The error that we see at this point, access denied for root at localhost using password no is normal. Next we'll type mysql root -p, hit enter. This will prompt us for the password that we just created, my secret, hit enter. Try that again. Mysql -u root -p, hit enter. There we go. Next we need to open up the hplus_db.spl script. We're going to copy the entire contents of this script and paste it into our mySQL prompt. As you can see, that went very quickly. If we scroll up, we can see that there's a table created, several insert statements, that a user was created with different permissions granted, that the database was created. Next we'll type quit and we'll log in again with the user that was just created. This will prompt us for our password. We'll show the databases available for this user. We'll use the hplus_db, and we'll finish this up by running a select statement on the table created. And that's it, we're now ready to configure our application servers to use the new mySQL database and use your credentials.

Contents