Create MariaDB Databases & Tables: A Guide

To create a database and table in MariaDB, you can follow these steps:

  1. To begin, log in to the MariaDB database by using the following command to connect to the database:
mysql -u 用户名 -p
  1. establishing a database
CREATE DATABASE 数据库名;
  1. Select the database you want to use:
USE 数据库名;
  1. Create a table:
CREATE TABLE 表格名 (
    列1 数据类型,
    列2 数据类型,
    ...
);

For example, to create a table named ‘users’ with columns ‘id’ and ‘username’, you can use the following command:

CREATE TABLE users (
    id INT PRIMARY KEY,
    username VARCHAR(50)
);
  1. Display databases in the system.
  2. List all tables.

The above are the simple steps to create databases and tables in MariaDB.

bannerAds