MySQL Data Base INSTALLATION testing Step-by-Step Guide
-
Introduction
SQL Part of “MYSQL” stands for Structured Query Language. MYSQL is a relational database from oracle where data is stored in tables.
MYSQL is open source and it is very fast, reliable and easy to use. MYSQL works in a client/server architecture. -
Download
To Download the MYSQL please access the following URL->https://dev.mysql.com/downloads/installer/.
Select the Windows (x86, 32-bit) MSI Installer to download the software. -
Double click on the software to open the installer.
Note:: If you are getting any error as shown below while launching MYSQL Software please download the .NET Framework from this link->https://www.microsoft.com/en-us/download/confirmation.aspx?id=42642 -
Click on Finish and Restart the System to reflect the changes.
-
Accept the License agreement and Click on Next.
-
Select the Setup Type as Custom and click on Next.
-
Select the products MYSQL Server and SQL Workbench and click on Next to download.
-
Check Requirements dialog shows the failing requirements.
-
MY SQL Server and Workbench is ready to be installed. Click on Execute to continue.
-
Continue with default values and click on Next.
-
Provide the username and password.
-
Deselect the option to start the MYSQL Server during System Startup.
-
Click on Finish to complete installation.
-
Start the MYSQL Server from the System by accessing ‘services.msc’ from the Start Menu. Select the MYSQL service and click on Start button to start the server.
-
Open MYSQL Command line Client from Start Menu. Execute the following Commands:
- Create Database testDB
- show databases
- use testdb
- show tables
- create table employee (name VARCHAR(20),salary INTEGER);
- INSERT into employee values (‘JOHN’,25000);
- Create a Maven Project add the mysql-connector.jar as an dependency for the project.
-
Execute the following code to retrieve the data from Database ‘testDB’.
-
Please find the console ouput::
Note:: Download the Microsoft Visual C++ from this link ->https://www.microsoft.com/en-in/download/details.aspx?id=40784.
Once the Microsoft Visual C++ setup is successful reopen the installer from the beginning to continue the process of installtation.
This jar file contains “com.mysql.jdbc.Driver” class it must be present in Build path of the project
in order to successful connection to mysql database.Copy the Maven Dependencies information from the
Repository URL mentioned below: https://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.21
Dependency Infromation:
1 2 3 4 5 |
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.21</version> </dependency> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
package org.totalqa.mysql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import com.mysql.jdbc.ResultSetMetaData; public class ConnectionManager { private static String url = "jdbc:mysql://localhost:3306/testDB"; private static String driverName = "com.mysql.jdbc.Driver"; private static String username = "root"; private static String password = "root"; private static Connection con; public static void main(String[] args) { try { Class.forName(driverName); try { //Create a connection to DB by passing Url,Username,Password as parameters con = DriverManager.getConnection(url, username, password); Statement stmt=con.createStatement(); //Executing the Queries stmt.executeUpdate("INSERT INTO testDB.employee VALUES ('TOTALQA',25000)"); ResultSet rs = stmt.executeQuery("SELECT * FROM testDB.employee"); rs.last(); int rows = rs.getRow(); ResultSetMetaData rsmd = (ResultSetMetaData) rs.getMetaData(); int cols = rsmd.getColumnCount(); System.out.println(rows +"--" + cols); String[][] inputArr= new String[rows][cols]; int i =0; rs.beforeFirst(); //Iterating the data in the Table while (rs.next()) { for(int j=0;j<cols;j++) { inputArr[i][j]=rs.getString(j+1); System.out.print(inputArr[i][j]); } System.out.println(); } } catch (SQLException ex) { ex.printStackTrace(); System.out.println("Failed to create the database connection."); } } catch (ClassNotFoundException ex) { ex.printStackTrace(); System.out.println("Driver not found."); } } } |
1 2 3 4 |
3 2 JOHN 25000 JAMES 15000 SCOTT 10000 |
After Step 12, (before #13) the wizard asks for Plugins and Extensions. There is checkbox for Enable X Protocol / MySQL as a Document Store. The default value is NOT checked. If this is checked then it enables other two items a) Text Box for Port Number which shows default value 33060. b) Checkbox for Open Firewall port for network access. Default value is NOT checked.
Should we keep this screen of wizard as Default? or what? I have a screenshot if you did like to see?
The default Port for MYSQL to be installed in 3306.
Yes, please proceed with default values.
Also make sure remember the username/password provided during the installation.