1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Rep Power

    How to get my database connection to work using XAMPP

    hi i have installed XAMPP and its got php and apache working fine but mysql does not work i get the error:

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\testDB.php on line 5
    couldn't connect localhost

    i have not configured anything for the database, because i don'nt know how to using XAMPP?
    how do I even create a database using XAMPP?
  2. #2
  3. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    London, UK
    Rep Power
    Originally Posted by http://www.apachefriends.org/en/xampp-windows.html#530
    * XAMPP and services
    For all NT/2000 users, in both packages you will find the install and uninstall files to build all servers as services in the respective directories.

    * apache_installservice.bat => Apache install as service/li>
    * apache_uninstallservice.bat => Apache uninstall as service
    * mysql_installservice.bat => MySQL install as service
    * mysql_uninstallservice.bat => MySQL uninstall as service

    After all changes don't forget to restart your system. Note! To uninstall the mysql service you must first of all have stopped the mysql service!
    * MySQL and PHP
    MySQL starts without a password for "root". So in PHP you can connect the MySQL-Server with: mysql_connect("localhost","root","");
    If you want to set a password for "root" in MySQL, please use "mysqladmin" under Console. For example:

    \...\xampp\mysql\bin\mysqladmin -u root password secret

    Attention. After changing the password for root, don't forget to inform PHPMyAdmin. Search the "config.inc.php" under \...\xampp\phpmyadmin\ and edit the following lines:

    $cfg['Servers'][$i]['user'] = 'root'; // MySQL SuperUser
    $cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP MySQL authentification

    Now the correct password for "root" is required, before PHPMyAdmin starts.

    Please see also the three methods in the Windows FAQ:
    Do your research next time. This was a 10 second google

    MySQL default installation does not come with a password set.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Rep Power

    Uninstall it and then reinstall it, it could be because of the installation error.



    Comments on this post

    • Winters disagrees : XAMPP is not something that is installed and that is not an installation error.

IMN logo majestic logo threadwatch logo seochat tools logo