To create a MySQL database and tables, and insert data, follow these steps:
mysql -u username -p
Replace username with your MySQL username. You will be prompted to enter your password.
CREATE DATABASE databasename;
Replace databasename with the name of the database you want to create.
USE databasename;
CREATE TABLE tablename ( column1 datatype, column2 datatype, ... );
Replace tablename with the name of the table you want to create, and column1, column2, etc. with the names of the columns in the table and their corresponding data types. For example:
CREATE TABLE employees ( id INT PRIMARY KEY, name VARCHAR(255), salary DECIMAL(10,2) );
INSERT INTO tablename (column1, column2, ...) VALUES (value1, value2, ...);
Replace tablename with the name of the table, and column1, column2, etc. with the names of the columns in the table. Replace value1, value2, etc. with the values you want to insert. For example:
INSERT INTO employees (id, name, salary) VALUES (1, 'John Smith', 50000);
You can insert multiple rows at once by using multiple VALUES clauses:
INSERT INTO employees (id, name, salary)
VALUES (1, 'John Smith', 50000),
(2, 'Jane Doe', 60000),
(3, 'Bob Johnson', 40000);
To check that the data was inserted correctly, you can use the SELECT statement to retrieve it from the table:
SELECT * FROM tablename;
Replace tablename with the name of the table. This will return all rows and columns from the table.
Note: These are just the basic steps for creating a database, tables, and inserting data in MySQL. There are many other features and options available, such as constraints, indexes, and more. Consult the MySQL documentation for more information.