Creating a MySQL Database using XAMPP

This tutorial assumes that you have XAMPP 1.7.3 installed. The procedure should be the same for other versions of XAMPP.

A XAMPP installation procedure for Windows can be found here.

Click on images for full sized versions.

Many applications, such as Joomla! require an SQL database as part of their setup.

With XAMPP installed, this is easy to do.

1) Open your browser and enter http://localhost/phpmyadmin. This will bring you to the MySQL setup page:

xampp-mysql-main-page-phpmyadmin-url

2) Enter a name for the database, then click on the Create button. The name must be 64 characters or less and composed of letters, numbers and underscores. Avoid using numbers at the start of the name. A good name should indicate the purpose of the database. For example: joomla_database or database_for_drupal. There should be no need to change the other settings:

xampp-mysql-main-page-enter-database-name

3) Ensure the database was successfully created:

xampp-mysql-database-created

This database can now be used by any application that requires a MySQL database – for example, Joomla!.

By default, the username for this database is root and the password is blank (there is none).

52 Comments

  • Alieu says:

    thanks it’s easy and straight forward

  • bbk says:

    Thank you so much!

  • Angie says:

    Thanks for the advice, very helpful!

  • Chanaka says:

    I really appreciate, All the best. 🙂

  • Dannyboy says:

    After following your php database creation instructions, my joomla web installion is unable to connect to the database. Any suggestions?

    • admin says:

      I am going to assume that:
      (1) you have a XAMPP install
      (2) you have not enabled any passwords or security features for XAMPP
      The most likely causes are:
      (1) wrong database type specified in the Joomla! install. It should be either MySQL or MySQLi (at least, I haven’t noticed any difference between the two).
      (2) your server is not localhost. It most cases it will be localhost, the only time it wouldn’t be localhost is if the MySQL server is on a different machine from the installation (but that is rarely the case).
      (3) you specified the wrong user name. For XAMPP it will almost always be root, unless you have added a database user, in which case it would be the database user name
      (4) you specified the wrong password. The default password for XAMPP is blank / empty. However, if you setup a root password for XAMPP or enabled security for XAMPP< the the root user will have a password and this must be entered.
      If you are running a different apache / mysql combination (like AMPPS), then you MUST creat a user for the database and use that user's name and password when configuring Joomla!.
      Hope this helps. If you still need help, we can try to work through it. It would help me to know what your setup is: are you installign under XAMPP, AMPPS, some other host. Which version of XAMPP, etc are you using. Which version of Joomla! are you using.

      • I’m using joomla 1.7 stable pack, i’ve checked everything following ur instructions, yet the database still return error number 2.

        • admin says:

          Which version of XAMPP are you using? I recommend using version 1.7.3 because you will have problems with Joomla! 1.7 on XAMPP 1.7.4 and XAMPP 1.7.7.
          Another possiblity might be where you installed XAMPP. XAMPP should be installed in its own directory (preferably C;
          xamp) – not C:/Program Files – because Windows 7 (and, I think Vista) blocks write access to that directory, so if XAMPP is running there, Windows might prevent it from writing to the disk (which it would need to do if it is creating a database).

  • Konloch says:

    Hey, thanks for this dude, I was busting my ass off looking for this, I owe you one.

  • yogi says:

    thank u somuch its helpful to beginners

    • admin says:

      You’re very welcome. We were all once beginners. I think too much of the help we find on the Internet tends to forget that. Thanks for the feedback.

  • William says:

    The link for locallhost/phpmyadmin takes me to the site but everything is in German. I am assuming the reason I can’t access the basic install of Joomla is because I haven’t created the database? Very new at this. any help is much appreciated. Thanks!

    • admin says:

      Hmm … I wonder how that happened?
      One possibility is you downloaded a German language version of XAMPP (assuming you are using XAMPP), otherwise, you downloaded a German version of phpMyAdmin.
      Another possibility is that you inadvertently set your install language to German (or, maybe you are using a German language version of Windows and phpMyAdmin is trying to be helpful by setting the language to German).
      Try the following:
      1) Find the heading: Oberfläche
      2) Underneath that will be a line and dropdown box with the heading: Sprache – Language
      3) Click on the dropdown box and select English
      Hopefully, that will set your language back to English.
      As for accessing Joomla!, you should be able to access the start / intro install page for Joomla! whether or not you have created a database.
      If you can’t, it is probably because you either:
      (1) did not install Joomla! in the htdocs folder / directory
      (2) you did not enter the correct URL to your Joomla! install. The URL is localhost/joomla_directory where joomla_directory is the name of the directory / folder you installed Joomla! into under htdocs

  • Bruce Wright says:

    It worked fine until I tried to install the database in Joomia 1.7.3. It then gives me a constant moving circle for a very long time. Any suggestions?

    • admin says:

      Off hand, I would think that either (1) the Apache server is not running or (2) the MySQL server is not running.
      The “constant moving circle” suggests the client (browser) is waiting for a connection. However, if you were able to go to the myphpadmin page and you were able to create a database, that kind of rules those out (although, it is always possible the MySQL server died in the interim – but it’s never happened to me).
      The only other thing I can think of is that you have the wrong user / password combination. sometimes, it takes longer to report back that a connection could not be made. The default user in XAMPP is root and the default is blank (i.e. nothing, there is no password).
      Thanks for your question and let me know how things work out.

  • keith says:

    How do I make a database for a membership system? Its a project and my ass of a teacher didn’t teach anything. Can anyone help?

  • fairu says:

    hi…can i know how to create table in mysql using xampp??????

  • manasa says:

    how to create table after database name is created?

  • sushma murthy says:

    hi, am new to xampp
    I have created new database in mysql and also created table, but am not able to retrieve that data on my html page and also connection is not happening what i should do am not getting?

    • admin says:

      XAMPP is just a package that contains Apache, MySQL, PHP, and Pear all in one package (it is also known as WAMPP (Windows), LAMPP (Linux) and MAMPP (Macintosh)).
      Your browser cannot directly access the MySQL database (or the data inside). To access and display the data, you need to use a script (it could be written in PHP) that accesses the MySQL database and then displays the result in a wbpage.
      W3Schools has really good tutorials on various web based subjects (so there is no point in me repeating / duplicating them). For example, this page shows how to connect to a MySQL databse using PHP.
      If your problem is that you cannot access the database when using something like Joomla!, WordPress, Drupal, etc, then it is likely you have the username and / or password wrong. The default username in XAMPP is root and teh default password is empty so you leave the field blank.

  • Pink Floyd says:

    I have a similar problem.
    How does the web server know WHERE the mySQL database is?
    Is this location fixed, relative to the localhost (i.e. Drive:/xampp/htdocs) ?
    Thanks

    • admin says:

      The location of the database has no relation to localhost.
      The database runs as a server that communicates using a network socket connection.
      The MySQL database server can even run on a different computer somewhere else on the network (if you like). The typical C api call would be:

          mysql_real_connect (
                  conn,           /* pointer to connection handler */
                  "localhost",    /* host to connect to */
                  "user_name",    /* user name */
                  "password",     /* password */
                  "test",         /* database to use */
                  0,              /* port (default 3306) */
                  NULL,           /* socket or /var/lib/mysql.sock */
                  0 );            /* flags (none) */
      

      (the code snippet was taken from here)
      You interact with the MySQL server via port 3306 (by default).
      You can also specify the address to bind the server to using –bind-address to pass the IP address to the server on startup.
      You can read more on that here.
      Unfortunately, I can’t be of more help because that goes well beyond the scope of the article (and, I am not doing anything in this general area).

  • Ronald Smith says:

    I have a problem when I click create it just stay still it doesnt do something plss help I need this database!

    • admin says:

      It is very hard to imagine what could have gone wrong – since the only thing you need to do is provide a database name and click on Create.
      The only two things I can think of are: (1) your browser is in some sort of funky state and not communicating properly with Apache, or (2) there is some funky problem with the MySQL server connection.
      If you get the phpmyadmin page then you know that Apache and MySQL are working. But if it stops working during you session, then you know that something must have gone down with either Apache or MySQL.
      Try closing and restarting your browser. If that doesn’t work, try restarting your computer.
      Finally, the only other thing I can think of is that perhaps Apache or MySQL is running on a different computer across a network and that connetion or computer is down – in which case talk to your IT specialist.

  • Ronald Smith says:

    I can get to localhost/phpmyadmin and i click database enter name and click create but it just stays it doesnt gives the message that database succesfully created its just on the same page! Now i will try restarting browser and if that doesn’t work restart computer!Thanks anyway!
    (by the way about my browser im using the newest version of opera)

    • admin says:

      I downloaded and installed Opera 11.61 and it worked fine.
      So, I don’t know why it hangs when trying to create a database. The fact that you can open the phpmyadmin page shows that the Apache server and MySQL server are both working.
      I wonder if there are some browser security or OS security settings that might be causing your problem?
      I would sugest asking for help on either phpmyadmin forum or MySQL forum. Be sure to specify: (1) your OS, (2) what version of XAMPP you are using, (3) what browser (and version) you are using.

  • Topmse says:

    hey i am trying to create a local host server on my system but it does not work.

    • admin says:

      Did you install XAMPP?
      Which version of XAMPP? I recommend 1.7.3 because I have had problems with 1.7.4 and 1.7.7. See here for installing XAMPP 1.7.3.
      Do you have port conflicts. Microsoft IIS commonly causes problems with Apache. See here for determining if you have port conflicts.
      What OS are you running. Windows 7 (and possibly Windows Vista) is more security focussed. Running XAMPP from C:\Program Files (x86) can cause problems.

  • Andrew Molo says:

    I have created a form and I want to fetch data from the phpmyadmin database using the form. Please help

    • admin says:

      Sorry, that’s beyond the scope of this article. Besides, I don’t do MySQL programming.
      However, you can try these resources:
      W3Schools – definitely the best online source for web related tutorials like html, xml, css, php, etc – so there is no point in me trying to duplicate their content.
      PHP MySQL Tutorial – looks reasonably decent, certainly as a complement to the W3Schools tutorial above.

  • sai says:

    thank u very much boss..

  • Damon says:

    XAMPP, WordPress and Joomla install
    My laptop has VISTA and the installation of XAMPP went smoothly. The apache webserver operates on port 80. My phpmyadmin allows me to create databases, and grant privileges. However, when I try installing wordpress it hangs on step 2 and joomla install is unable to connect to the database. I have attempted no less than 10 installs on each – all unsuccessful.
    I installed XAMPP on my computer running Windows 7, and both wordpress and joomla installed succesfully on the first try.

    • admin says:

      My best guess is that Vista is blocking the MySQL.
      Since I don’t have Vista, I am not sure exactly what it could be, but it might be one of the following:
      (1) the Vista firewall has blocked the port (3306) needed to connect to MySQL
      (2) Vista is blocking the MySQL service (or application)
      (3) perhaps the MySQL app needs to run with administrator privileges.
      As I said, I don’t have Vista, so my guesses might be wrong.

  • yana says:

    im using xampp version 1.7.7. Is it complicated to use it?

    • admin says:

      XAMPP 1.7.7 is no more complicated to use than XAMPP 1.7.3.
      There are two main differences: (1) the look and feel of the GUI has changed a little bit – but the functions are still the same; (2) XAMPP 1.7.7 has stricter error reporting enabled by default – this causes problems with some applications (like Joomla! 1.5, 1.6 and 1.7 – it works fin with Joomla! 2.5).

  • yana says:

    can it work with microsoft access? or dreamweaver? which better for creating a database system?

    • admin says:

      Unfortunately, your questions are beyond the scope of the article. The article was about creating a database that can be used by a CMS (like Joomla! or WordPress). It is not about database programming or development.
      However …
      Microsoft Access is a different database management application. By default Microsoft Access uses the Microsoft Jet Database. The database with XAMPP is MySQL.
      You can definitely connect Microsoft Access to MySQL. There is nice tutorial on that here and here (section 21.1.5.4.3 – about half way down the page).
      Dream Weaver can definitely be used for web development. Personally, I don’t use it. I use available CMSes (like WordPress and Joomla) and find templates I like (maybe customizing them slightly).
      My primary focus is on content creation (writing articles) and not web site development. Sorry.
      Thanks again for your question.

  • FASLU says:

    how retrive xamp database to my html page

    • admin says:

      Your browser cannot directly access the MySQL database (or the data inside). To access and display the data, you need to use a script (it could be written in PHP) that accesses the MySQL database and then displays the result in a webpage.
      W3Schools has really good tutorials on various web based subjects (so there is no point in me repeating / duplicating them). For example, this page shows how to connect to a MySQL databse using PHP.

  • manikanta says:

    thanks for giving valuable guidence by this document

  • Asha sukhwal says:

    By default where the database wil be saved.

    • richardsplanet says:

      The database is stored in /xampp/mysql/data

      Inside the /data folder you will find a number of directories. Each directory corresponds to a database you have created. The files for each database are found inside those directories.

      However, directly manipulating those files usually ends badly.