Create MariaDB Databases & Tables: A Guide
To create a database and table in MariaDB, you can follow these steps:
- To begin, log in to the MariaDB database by using the following command to connect to the database:
mysql -u 用户名 -p
- establishing a database
CREATE DATABASE 数据库名;
- Select the database you want to use:
USE 数据库名;
- 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)
);
- Display databases in the system.
- List all tables.
The above are the simple steps to create databases and tables in MariaDB.