how to install mariadb on linux debian

June 12, 2020

Update your package index

sudo apt update

Install Mariadb Server

sudo apt install mariadb-server

Log in into the Mariadb shell

sudo mysql

Suppose you run into this error while running mysql

ERROR 2002 (HY000): Cant connect to local MySQL server through socket /var/run/mysqld/mysqld.sock (2)

Run

sudo service mysqld start

Mysql

Comments

Single line comments are preceded with -

-Update all:
SELECT * FROM Product;

Multi-line comments start with /* and end with */

/* Select all the columns
of all the records
in the Products table: */
SELECT * FROM Products;

Connect to MySQL as a root user

To start working with mysql you need to establish an active SSH session on your server

sudo mysql -u root -p

Create a new Mysql user

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Delete a user

DROP USER 'username'@'localhost'

SELECT — choose specific data from your database UPDATE — update data in your database DELETE — deletes data from your database INSERT INTO — inserts new data into a database CREATE DATABASE — generate a new database ALTER DATABASE — modify an existing database CREATE TABLE — create a new table in a database ALTER TABLE — change the selected table DROP TABLE — delete a table CREATE INDEX — create an index (search key for all the info stored) DROP INDEX — delete an index

Tables

Create a table

CREATE TABLE [IF NOT EXISTS] table_name(
column_list
);
CREATE TABLE user(
uname VARCHAR(100),
fav_color VARCHAR(100),
age VARCHAR(20)
);

show tables — call a list of all tables associated with a database. DESCRIBE tablename; — see the columns of your table. DESCRIBE tablename column_name; — review the information of the column in

Delete table

DROP TABLE table_name;

Columns

Columns are defined by different storage types. i.e CHAR, VARCHAR, TEXT, BLOB, EUT.

Add a new column

ALTER TABLE table
ADD [COLUMN] column_name;

Deleting/ dropping a column

ALTER TABLE table_name
DROP [COLUMN] column_name;

Inserting a new row

INSERT INTO table_name (field1, field2, ...) VALUES (value1,
value2, ...)

Selecting specific data from a row

INSERT INTO table_name (field1, field2, ...) VALUES (value1,
value2, ...)

Profile picture

Written by Davis Bwake A fullstack developer who likes JavaScript and everything web 3.0(BlockChain..) follow me on twitter

My tech stack is HTML, CSS,JavaScript, ReactJS, NodeJS, Solidity

Am currently open to remote job oppurtunities.

Checkout my projects

YouTube