Create new database from command line

To create a new database from the command line, you'll need to use a database management system (DBMS) such as MySQL, PostgreSQL, or SQLite. Here are the steps for each:

MySQL

  1. Open a terminal or command prompt.
  2. Install MySQL if you haven't already. You can download it from the official MySQL website.
  3. Start the MySQL server by running the command mysql -uroot -p (replace root with your MySQL username and p with your password).
  4. Create a new database by running the command CREATE DATABASE mydatabase (replace mydatabase with the name of your new database).
  5. Verify that the database was created by running the command SHOW DATABASES;.

PostgreSQL

  1. Open a terminal or command prompt.
  2. Install PostgreSQL if you haven't already. You can download it from the official PostgreSQL website.
  3. Start the PostgreSQL server by running the command pg_ctl start (on macOS or Linux) or net start postgres (on Windows).
  4. Create a new database by running the command createdb mydatabase (replace mydatabase with the name of your new database).
  5. Verify that the database was created by running the command psql -l (list all databases).

SQLite

  1. Open a terminal or command prompt.
  2. Install SQLite if you haven't already. SQLite is usually included with most operating systems, but you can also download it from the official SQLite website.
  3. Create a new database by running the command sqlite3 mydatabase.db (replace mydatabase.db with the name of your new database).
  4. Verify that the database was created by running the command .tables (list all tables in the database).

Note: In SQLite, the database file is created automatically when you run the sqlite3 command. You don't need to create a separate database management system like MySQL or PostgreSQL.

That's it! You should now have a new database created from the command line.