Table of Contents
Table of Contents
MySQL is a relational database management system (RDBMS) developed by Oracle that is based on structured query language (SQL).
This tutorial covers the MySQL database running on a Linux server. This tutorial will also cover the generation and use a simple database. The interface language of the MySQL database is the standard SQL (Standard Query Language) which allows for inserts, updates and queries of data stored in relational tables.
The SQL language is also used for the administration of the database for the creation and modification of tables, users and access privileges. Tables are identified by unique names and hold data in a row and column (record) structure. A fixed number of named columns are defined for a table with a variable number of rows.
Step 1: Update your system
sudo apt update
sudo apt upgrade
Step 2 : Run the following command to install MySQL,Then give your password and hit ENTER.
sudo apt install mysql-server
Press “Y” to continue.
Step 3: To verify the installation or to know the version enter the following
commands in your Terminal.
mysql –version
create a database named testdb . In order to do that, log in to the MySQL console with the command:
sudo mysql -u root
Let’s create a database using the following command:
CREATE DATABASE testdb;
To see the database created use the following command:
show databases;
Next, create a user with permission to access the new database. In this example, create the user dbuser with the command:
CREATE USER ‘dbuser’@’localhost’ IDENTIFIED BY ‘PASSWORD’;
When you create a new user, the user doesn’t automatically have access to the database.
Give the user access to the database with the command:
GRANT ALL ON testdb.* To ‘dbuser’@’localhost’ WITH GRANT OPTION;
FLUSH PRIVILEGES; Quit
Once you install a database, you can use your database server to work with all types of applications and services.
● SELECT – extracts data from a database
● UPDATE – updates data in a database
● DELETE – deletes data from a database
● INSERT INTO – inserts new data into a database
● CREATE DATABASE – creates a new database
● ALTER DATABASE – modifies a database
● CREATE TABLE – creates a new table
● ALTER TABLE – modifies a table
● DROP TABLE – deletes a table
● CREATE INDEX – creates an index (search key)
● DROP INDEX – deletes an index