Home » Programming » Databases

How to Run an SQL File in MySQL (or MariaDB) on Linux/Ubuntu

How to Run a SQL File in MySQL/MariaDB on Linux/Ubuntu

Here is an article outlining several methods for running SQL files in MySQL on Linux/Ubuntu. Whether you’re installing a package, following a tutorial, or restoring a backup – it’s useful to be able to execute an SQL script from a file and have it do all of the work for you, rather than having to type it all out. Most GUI database managers have a simple import option prominently displayed in the menu bar – so here’s how to do it from the command line … Read more

Home » Programming » Databases

LinuxScrew Guide for Developers Learning PostgreSQL

Learn PostgreSQL Guide

This page serves as the index for our PostgreSQL tutorials. It will be updated as new articles in the series are added. This guide is intended for developers who are just getting started with PostgreSQL and are looking for a simple resource to get them up and running. PostreSQL Guide Introduction: What is PostgreSQL? Why Use It ?

Home » Programming » Databases

PostreSQL Guide Introduction: What is PostgreSQL? Why Use It ?

PostgreSQL Introduction - What is PostgreSQL

This article is part of the LinuxScrew Guide for Developers Learning PostgreSQL. PostgreSQL is a relational database management system. It is similar to other networked SQL database servers like MySQL/MariaDB and Microsoft SQL, but there are some key differences in features and functionality. PostgreSQL vs Other Database Systems You can see a comparison of PostgreSQL and other database systems here. In short, while MySQL is the most popular open source database system, PostgreSQL is more advanced. PostgreSQL is object oriented, can store a larger number of types … Read more

Home » Programming » Databases

How to Use the MySQL/MariaDB COUNT Function, With Examples

MySQL Count

This quick article will demonstrate how to use the MySQL/MariaDB COUNT function to count the number of records returned by a query. MySQL/MariaDB COUNT Function Syntax COUNT(query) Note that: query can be an SQL query or a string representing a column name Null values found by the query will not be counted The COUNT function will return the number of matching records for a query and should be combined with the SELECT statement to output the result. Example Data The below examples use the following … Read more

Home » Programming » Databases

The MySQL/MariaDB DELETE Statement – How to Use It

MySQL Delete

Being able to delete data from a table in a database is a pretty important thing – This article will show you how it’s done in MySQL/MariaDB. MySQL DELETE Statement Syntax In its basic usage, the DELETE operator is used in conjunction with a WHERE query to delete records matching that query: DELETE FROM table WHERE query; Note that: table is the table you wish to delete records from query is the query that defines the conditions records should match to be deleted Safety First! Please … Read more

Home » Programming » Databases

How to List/Show Users in MySQL/MariaDB

MySQL Show List Users

This short article will show you how to list all of the users on your MySQL server. MySQL Users and Permissions MySQL databases usually have access granted to only certain users, each with their own permissions limiting what they can and can’t do on that specific database. As there are often multiple databases on a server, there will be several user accounts – some for different databases, some from different hosts – so it’s useful to be able to list them all out quickly. Command … Read more

Home » Programming » Databases

How to Update Records – MySQL UPDATE Statement

MySQL Update

This article will show you how to use the MySQL/MariaDB UPDATE statement to update existing database records. MySQL/MariaDB UPDATE Syntax The syntax for the MySQL UPDATE statement requires the use of two keywords, UPDATE, and SET, and is as follows: UPDATE table SET column = value WHERE conditions; Note that: table is the name of the table which contains the records to be updated column = value defines which column to update and what the new value for that column should be Multiple column/value pairs can be defined, separated by a … Read more

Home » Programming » Databases

How to Use MySQL ‘alias’ to Make Queries Easier to Read

MySQL Alias

This article will explain and demonstrate the use of aliases in MySQL (and MariaDB). MySQL queries can get pretty gnarly – especially if you’re selecting multiple columns from multiple tables. An alias statement is a great tool for simplifying these queries. An alias is just another name for the column or table in question, which you can use to refer to the column or table by. It’s a nickname that can be used to quickly refer to something complex to save time when writing queries. MySQL Column Alias … Read more

Home » Programming » Databases

Limit Column Values With The MySQL CHECK Constraint [Examples]

MySQL CHECK CONSTRAINT

This article will demonstrate the usage of the SQL CHECK Constraint to limit column values, as used in MySQL/MariaDB. The SQL CHECK constraint allows you to define limitations to the value which can appear in a table column. It also allows you to apply constraints to a whole table, letting you restrict a column’s values based on the values of other columns in the table row. This behavior is useful for making sure you are only getting valid data inserted into your database. For example, you might … Read more

Home » Programming » Databases

Default MySQL/MariaDB Port, Finding It, Changing It

Changing the MySQL Port

This article will show you how to find the default or current MySQL (or MariaDB) port and how to change it. What is a Port? A port is a numerical identifier for a communication endpoint on a computer network. Or, put simpler, it’s a unique number on your computer that points to a specific program that is running so that other programs can connect to it. MySQL/Maria DB, being networked database services, expose themselves to other computers via a configured port, allowing other computers to connect to and … Read more