Skip to main content
PHP Blog

Back to all posts

How to Create Database Using Xampp Shell?

Published on
5 min read
How to Create Database Using Xampp Shell? image

Best Tools for Creating Databases with XAMPP to Buy in September 2026

1 Office Suite 2026 Special Edition for Windows 11-10-8-7-Vista-XP | PC Software and 1.000 New Fonts | Alternative to Microsoft Office | Compatible with Word, Excel and PowerPoint

Office Suite 2026 Special Edition for Windows 11-10-8-7-Vista-XP | PC Software and 1.000 New Fonts | Alternative to Microsoft Office | Compatible with Word, Excel and PowerPoint

  • COMPLETE OFFICE SOLUTION: ONE SUITE FOR WORD PROCESSING, SPREADSHEETS, & MORE!

  • VAST CREATIVE OPTIONS: 1,000 FONTS AND 20,000 CLIPART IMAGES INCLUDED!

  • USER-FRIENDLY SETUP: QUICK, EASY INSTALLATION FOR ALL WINDOWS VERSIONS!

BUY & SAVE
$14.99
Office Suite 2026 Special Edition for Windows 11-10-8-7-Vista-XP | PC Software and 1.000 New Fonts | Alternative to Microsoft Office | Compatible with Word, Excel and PowerPoint
2 LibreOffice Suite 2026 Home and Student for - PC Software Professional Plus - compatible with Word, Excel and PowerPoint for Windows 11 10 8 7 Vista XP 32 64-Bit PC

LibreOffice Suite 2026 Home and Student for - PC Software Professional Plus - compatible with Word, Excel and PowerPoint for Windows 11 10 8 7 Vista XP 32 64-Bit PC

  • COMPLETE OFFICE SUITE: WORD PROCESSING, SPREADSHEETS & PRESENTATIONS!

  • OVER 20,000 CLIPART IMAGES & DEDICATED EMAIL TECH SUPPORT INCLUDED!

  • FULLY COMPATIBLE WITH ALL MICROSOFT OFFICE FORMATS ON MULTIPLE WINDOWS!

BUY & SAVE
$12.99
LibreOffice Suite 2026 Home and Student for - PC Software Professional Plus - compatible with Word, Excel and PowerPoint for Windows 11 10 8 7 Vista XP 32 64-Bit PC
3 Database Development For Dummies

Database Development For Dummies

  • QUALITY ASSURANCE: EACH BOOK IS THOROUGHLY INSPECTED FOR QUALITY.
  • AFFORDABLE PRICES: SAVE MONEY WHILE ENJOYING GREAT READS.
  • SUSTAINABLE CHOICE: BUY USED, REDUCE WASTE AND SUPPORT RECYCLING.
BUY & SAVE
$32.42 $41.99
Save 23%
Database Development For Dummies
4 Just Use Postgres!: All the database you need

Just Use Postgres!: All the database you need

BUY & SAVE
$59.99
Just Use Postgres!: All the database you need
5 EZ Home and Office Address Book Software

EZ Home and Office Address Book Software

  • SEAMLESS COMPATIBILITY: WORKS WITH ALL WINDOWS VERSIONS, INCLUDING XP!
  • CUSTOM LABELS: EASY PRINTING OF COLORFUL LABELS WITH CLIP ART!
  • FLEXIBLE ORGANIZATION: CREATE MULTIPLE DATABASES FOR HOME AND BUSINESS!
BUY & SAVE
$29.95
EZ Home and Office Address Book Software
6 Database Design for Mere Mortals: 25th Anniversary Edition

Database Design for Mere Mortals: 25th Anniversary Edition

BUY & SAVE
$36.43 $54.99
Save 34%
Database Design for Mere Mortals: 25th Anniversary Edition
7 Fundamentals of Database Systems: Concepts, Design, and Applications: A Complete Guide to DBMS, Relational Models, SQL, NoSQL, Cloud Databases, and Advanced Data Management

Fundamentals of Database Systems: Concepts, Design, and Applications: A Complete Guide to DBMS, Relational Models, SQL, NoSQL, Cloud Databases, and Advanced Data Management

BUY & SAVE
$1.99
Fundamentals of Database Systems: Concepts, Design, and Applications: A Complete Guide to DBMS, Relational Models, SQL, NoSQL, Cloud Databases, and Advanced Data Management
+
ONE MORE?

To create a database using XAMPP shell, you first need to open the XAMPP control panel and start the MySQL server. Once the server is running, open the XAMPP shell and type the command "mysql -u root -p" to login to the MySQL command line interface.

After entering your MySQL root password, you can then create a new database by typing "CREATE DATABASE database_name;" where "database_name" is the name you want to give to the new database.

To switch to the newly created database, type "USE database_name;" and you can start creating tables and adding data to your database. Remember to always end each SQL statement with a semicolon (;).

Once you have finished creating your database, you can exit the MySQL command line interface by typing "exit" or pressing Ctrl + D.

What is the syntax for adding a new column to a table in XAMPP shell?

To add a new column to a table in XAMPP shell, you can use the following syntax:

ALTER TABLE table_name ADD column_name data_type;

Replace table_name with the name of the table you want to add a column to, column_name with the name of the new column, and data_type with the data type of the new column (e.g., VARCHAR, INT, etc.).

How to drop a table in XAMPP shell?

To drop a table in XAMPP shell, you can use the following steps:

  1. Open the XAMPP control panel and start the Apache and MySQL services.
  2. Open the XAMPP shell by clicking on the "Shell" button in the XAMPP control panel.
  3. In the XAMPP shell, log in to MySQL by typing the following command and pressing enter: mysql -u root -p
  4. You will be prompted to enter the MySQL root password. Enter the password and press enter.
  5. Once logged in to MySQL, select the database that contains the table you want to drop by typing the following command and pressing enter: use database_name; (Replace "database_name" with the name of your database)
  6. Finally, to drop the table, type the following command and press enter: DROP TABLE table_name; (Replace "table_name" with the name of the table you want to drop)
  7. After executing the command, the table will be dropped from the database.

Note: Dropping a table will permanently delete all the data and structure of the table, so make sure you have a backup of the data if needed.

What is the command to truncate a table in XAMPP shell?

To truncate a table in XAMPP shell, you can use the following command:

TRUNCATE TABLE table_name;

Replace "table_name" with the name of the table you want to truncate. Make sure to use this command carefully as it will delete all the data in the specified table.

What is the command to import a database in XAMPP shell?

To import a database in XAMPP shell, you can use the following command:

mysql -u [username] -p [database_name] < [path_to_sql_file]

Replace [username] with your MySQL username, [database_name] with the name of the database you want to import the data into, and [path_to_sql_file] with the path to the SQL file you want to import.

You will be prompted to enter the password for your MySQL username. Enter the password and press Enter to start importing the database.

How to set auto increment for a column in XAMPP shell?

To set auto increment for a column in XAMPP shell, you can use SQL commands to alter the table structure. Here's how you can do it:

  1. Open the XAMPP shell or command prompt.
  2. Log in to the MySQL database by entering the following command:

mysql -u username -p

Replace "username" with your MySQL username.

  1. Enter your MySQL password when prompted.
  2. Select the database where the table is located by entering the following command:

USE database_name;

Replace "database_name" with the name of your database.

  1. Now, you can alter the table structure to set auto increment for a column by executing the following SQL command:

ALTER TABLE table_name MODIFY column_name INT auto_increment;

Replace "table_name" with the name of the table and "column_name" with the name of the column for which you want to set the auto increment.

  1. You can also set the initial value for the auto increment column by using the following SQL command:

ALTER TABLE table_name AUTO_INCREMENT = value;

Replace "table_name" with the name of the table and "value" with the initial value you want to set.

  1. Verify that the auto increment has been set by describing the table using the following SQL command:

DESCRIBE table_name;

This will display the table structure, including the auto increment settings for the specified column.

That's it! You have successfully set auto increment for a column in XAMPP shell.

How to drop a unique index in XAMPP shell?

To drop a unique index in XAMPP shell, follow these steps:

  1. Open the XAMPP shell by clicking on the "XAMPP Shell" shortcut in the XAMPP control panel.
  2. Enter the following command to log in to MySQL:

mysql -u root -p

  1. Enter the password for the MySQL root user when prompted.
  2. Switch to the database where the unique index is located. You can do this with the following command, replacing your_database_name with the name of your database:

use your_database_name;

  1. Once you are in the correct database, you can drop the unique index using the following command, replacing your_index_name with the name of the unique index:

ALTER TABLE your_table_name DROP INDEX your_index_name;

  1. After running the command, the unique index will be dropped from the specified table in the selected database.
  2. You can exit the MySQL shell by typing:

exit;

  1. Close the XAMPP shell window.

That's it! You have successfully dropped a unique index in XAMPP shell.