banner



How To Create Database In Phpmyadmin Xampp

Database setup using XAMPP

This is a short introduction to help you setup and test access to your database using a local web server (XAMPP). For more information on SQL commands, please refer to database textbook(s).
(Please let me know if you find any errors or omissions in the document —Upsorn Praphamontripong, 8-August-2021)


XAMPP is an open source package that is widely used for PHP development. XAMPP contains MariaDB, PHP, and Perl; it provides a graphical interface for SQL (phpMyAdmin), making it easy to maintain data in a relational database.

If you have not installed XAMPP, please refer to XAMPP-setup to install and set up XAMPP.

Assuming that you have already set up XAMPP

  • Start the database server ("MySQL Database")
  • Start the PHP environment ("Apache Web Server")

Note:phpMyAdmin  runs on a PHP environment. To usephpMyAdmin  to manage databases, Apache Web server must be started.

Reminder: be sure to stop the server when you are done. Leaving the servers running consumes energy and may later prevent the servers from starting (in particular, MySQL server).


Access phpMyAdmin

  1. Open a web browser, enter a URLhttp://localhost   to access XAMPP dashboard
  2. SelectphpMyAdmin  tab

XAMPP dashboard

Alternatively, you may accessphpMyAdmin  via the XAMPP manager / controller, clickGo to Application  button to access XAMPP dashboard.

The main page should look similar to the following
screen showing the main page of phpMyAdmin


Add a user account

  1. On thephpMyAdmin  screen, selectUser accounts  tab.
  2. SelectAdd user account  link.
  3. Enter user name and password of your choice. Note: do not use any of your official accounts such as UVA account.
  4. SelectLocal  forHost name
  5. CheckCreate database with same name and grant all privileges
  6. CheckGrant all privileges on wildcard name (username\_%)
  7. CheckCheck all  forGlobal privileges
  8. At the bottom-right of the screen. click theGo  button

Do not change or update theroot  account. If you may forget or need to reset your password, you can use theroot  account to manage users.

sample screen to add a user account

To verify that the account has been created, go toUser accounts  tab. You should see the newly created user account (as shown below).

sample screen showing the account has been created


Create a database

Let's create aguestbook  database. To create a database, there are several options.

You may use the

Create database

  feature.

  • On thephpMyAdmin  screen, select theDatabases  tab. Alternatively, you may click theNew  link on the left panel.
  • Under theCreate database,  enter a Database name
  • Click theCreate  button

screen showing the create database screen of phpMyAdmin

You may run the SQL command to create a database.

  • On thephpMyAdmin  screen, select theSQL  tab
  • EnterCREATE DATABASE guestbook;
    Note: SQL commands are not case sensitive. This example uses uppercase and lowercase simply to make it easy to read.
  • Click theGo  button to run the command.
    • For Mac users, you may pressControl+Enter  to run
    • For Windows users, you may pressControl+Enter  to run

screen showing the SQL command to create a database


Create a table

Let's create a table namedentries.  To create a table, there are several options.

You may use the

Create table

  feature.

  • On thephpMyAdmin  screen, select theguestbook  database.
  • Select theStructure  tab.
  • Under theCreate table,  enter a table name and the number of columns.
  • Click theGo  button. This will prompt you to enter the column information.

screen showing the create table screen of phpMyAdmin

You may run the SQL command to create a table.

  • On thephpMyAdmin  screen, select theSQL  tab
  • Enter the following code
    USE guestbook;  CREATE TABLE entries (guestName VARCHAR(255), content VARCHAR(255),      entryID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(entryID));

    screen showing the SQL command to create a table

    If you already selected theguestbook  database (on the left panel), no need to include USE guestbook in your SQL to run.

    screen showing the SQL command to create a table

  • Click theGo  button to run the command.
    • For Mac users, you may pressControl+Enter  to run
    • For Windows users, you may pressControl+Enter  to run

Insert data

To insert data into a table, there are several options.

You may use the

Insert

  feature.

  • On thephpMyAdmin  screen, select theguestbook  database, select theentries  table.
  • Select theInsert  tab.
  • For each record of data to be inserted, enter the value for each column.
  • Click theGo  button.

screen showing the insert data screen of phpMyAdmin

You may run the SQL command to insert data.

  • On thephpMyAdmin  screen, select theguestbook  database, select theentries  table.
  • Select theSQL  tab
  • Enter the following code
    INSERT INTO entries (guestName, content) values ("Humpty", "Humpty's here!"); INSERT INTO entries (guestName, content) values ("Dumpty", "Dumpty's here too!");

    screen showing the SQL command to insert data into a table

  • Click theGo  button to run the command.
    • For Mac users, you may pressControl+Enter  to run
    • For Windows users, you may pressControl+Enter  to run

Retrieve data

To retrieve data from a table, there are several options.

You may use the

Browse

  feature.

  • On thephpMyAdmin  screen, select theguestbook  database, select theentries  table.
  • Select theBrowse  tab. This will display all existing records of the table.

screen showing the Browse screen of phpMyAdmin

You may run the SQL command to retrieve data.

  • On thephpMyAdmin  screen, select theguestbook  database, select theentries  table.
  • Select theSQL  tab
  • Enter the following code
    SELECT * FROM entries;

    screen showing the SQL command to retrieve data from a table

  • Click theGo  button to run the command.
    • For Mac users, you may pressControl+Enter  to run
    • For Windows users, you may pressControl+Enter  to run

Import SQL file

  • Create a blank file namedfriendbook.sql.  Paste the following content in the file
    CREATE TABLE friends    (friendName VARCHAR(255),     phone VARCHAR(255),     entryID INT NOT NULL AUTO_INCREMENT,     PRIMARY KEY(entryID));  INSERT INTO friends (friendName, phone) values ("Humpty", "111-111-1111"); INSERT INTO friends (friendName, phone) values ("Dumpty", "222-222-2222");              
  • On thephpMyAdmin  screen, select theguestbook  database
  • Select theImport  tab

    screen showing how to import SQL file

  • Choose the .sql file to import

    screen showing how to import SQL file

  • Click theGo  button to run the command.
    • For Mac users, you may pressControl+Enter  to run
    • For Windows users, you may pressControl+Enter  to run

Export SQL file (back up your database)

  • On thephpMyAdmin  screen, select theguestbook  database
  • Select theExport  tab

    screen showing how to export SQL file

  • Click theGo  button to run the command.

    screen showing how to export SQL file

    • For Mac users, you may pressControl+Enter  to run
    • For Windows users, you may pressControl+Enter  to run

How To Create Database In Phpmyadmin Xampp

Source: http://www.cs.virginia.edu/~up3f/cs4750/supplement/DB-setup-xampp.html

Posted by: weidmanatudeas.blogspot.com

0 Response to "How To Create Database In Phpmyadmin Xampp"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel