The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to reset my MySQL Password

Discussion in 'Database Discussions' started by Dionoh, Jan 6, 2012.

  1. Dionoh

    Dionoh Member

    Joined:
    Jan 6, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    hi,

    i'm new in this world.
    but i have a question about my MySQl Connection.

    I want to make my own CMS System but i cant go any further because of this error:


    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'MY USERNAME'@'localhost' (using password: YES) in /home/dionjo/public_html/cms/functions.php on line 5
    Access denied for user MY USERNAME'@'localhost' (using password: YES)

    :confused::confused::confused:


    Can please anyone help me?

    What do i have to do?
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,471
    Likes Received:
    199
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Have you created the database previous to running the setup script for your CMS?

    This is a cut n paste from another thread that describes whats required and how to get there:

    You'll need the database setup first from within your cPanel MySQL databases section.

    In this order on that page you should follow exactly:

    1) You want a database named whatever. So, you type in whatever to the New Database box you see there, and click Create. You're told it has been created. Click Go Back.

    2) Scroll down to the section called MySQL Users. We need to add a user. Type in the name david (as an example) type in davids password, twice, or generate one here using the tool provided. Now click Create User. You're told it has been created, click Go Back.

    3) Next we need to set that new user to use that new database. Scroll down to bottom of page again to find the Add User to Database. Select the user named cpanelusername_david and on the other drop down menu just below, select the database cpanelusername_whatever. Next click Add.

    On next page, click the option at top for "All Privileges" and click Make Changes at bottom. You are then notified that cpanelusername_david was added to database cpanelusername_whatever

    We put all those details together in one place, as they will be needed for your CMS install.

    host: localhost
    user: cpanelusername_david
    password: whateveryouused
    database: cpanelusername_whatever

    All names are of course examples, edit to your needs.

    HTH!
     
  3. Dionoh

    Dionoh Member

    Joined:
    Jan 6, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I did that now.
    But i still get a error i will show you my code:

    This is my config.php

    PHP:
    <?php

    // Database configuration
    $host "localhost";
    $username "dionjo_member";
    $password "my password";
    $database "dionjo_cms";

    // Base URL
    define('BASE_URL''http://localhost/cms');

    ?>



    And this is my functions.php

    PHP:
    <?php

    require_once 'config.php';

    // Connect to MySQL database
    function connect() {
        
    mysql_connectDB_HOSTDB_USERDB_PASS) or die('DB_HOST, DB_USER, DB_PASS is misschien fout. ' mysql_error());
        
    mysql_select_dbDB_NAME) or die('verkeerde database. ' mysql_error());
    }


    // Display title
    function title() {
        if (
    $_GET['id']) {
            
    $pageID = (int) $_GET['id'];

            
    $result mysql_query("SELECT title FROM pages WHERE id='$pageID'");
            
    $row mysql_fetch_array($result);
            
            echo 
    $row['title'];
        } else {
            
    $result mysql_query("SELECT value FROM settings WHERE name='homeTitle'");
            
    $row mysql_fetch_array($result);
            
            echo 
    $row['value'];
        }
    }

    // Display page title
    function pageTitle() {
        if (
    $_GET['id']) {
            
    $pageID = (int) $_GET['id'];
        
            
    $result mysql_query("SELECT title FROM pages WHERE id='$pageID'");
            
    $row mysql_fetch_array($result);
        
            echo 
    $row['title'];
        } else {
            
    $result mysql_query("SELECT value FROM settings WHERE name='homePage'");
            
    $row mysql_fetch_array($result);
            
            
    $pageID $row['value'];
            
            
    $result mysql_query("SELECT title FROM pages WHERE id='$pageID'");
            
    $row mysql_fetch_array($result);
            
            echo 
    $row['title'];
        }
    }

    // Display page body
    function pageBody() {
        if (
    $_GET['id']) {
            
    $pageID = (int) $_GET['id'];

            
    $result mysql_query("SELECT body FROM pages WHERE id='$pageID'");
            
    $row mysql_fetch_array($result);
            
            echo 
    $row['body'];
        } else {
            
    $result mysql_query("SELECT value FROM settings WHERE name='homePage'");
            
    $row mysql_fetch_array($result);
            
            
    $pageID $row['value'];
            
            
    $result mysql_query("SELECT body FROM pages WHERE id='$pageID'");
            
    $row mysql_fetch_array($result);
            
            echo 
    $row['body'];
        }
    }

    // Display page date
    function pageDate() {
        if (
    $_GET['id']) {
            
    $pageID = (int) $_GET['id'];

            
    $result mysql_query("SELECT date FROM pages WHERE id='$pageID'");
            
    $row mysql_fetch_array($result);
            
            
    // Convert Unix time to date
            
    $date date('M d, Y'$row['date']);
            
            echo 
    $date;
        } else {
            
    $result mysql_query("SELECT value FROM settings WHERE name='homePage'");
            
    $row mysql_fetch_array($result);
            
            
    $pageID $row['value'];
            
            
    $result mysql_query("SELECT date FROM pages WHERE id='$pageID'");
            
    $row mysql_fetch_array($result);
            
            
    // Convert Unix time to date
            
    $date date('M d, Y'$row['date']);
            
            echo 
    $date;
        }
    }

    // List the pages
    function listPages() {
        
    // List the home page first
        
    $result mysql_query("SELECT value FROM settings WHERE name='homePage'");
        
    $row mysql_fetch_array($result);
        
        
    $homeID $row['value'];
        
        
    $result mysql_query("SELECT title FROM pages WHERE id='$homeID'");
        
    $row mysql_fetch_array($result);
        
        
    $homeTitle $row['title'];
        
        echo 
    "<li><a href='" BASE_URL "/index.php'>$homeTitle</a></li>";
        
        
    // List the rest of the pages
        
    $result mysql_query("SELECT id, title FROM pages");
        
        while (
    $row mysql_fetch_array($result)) {
            
    // Do not list the home page twice
            
    if ($row['id'] != $homeID) {
                
    $pageID $row['id'];
                
    $pageTitle $row['title'];
                
                echo 
    "<li><a href='" BASE_URL "/index.php?id=$pageID'>$pageTitle</a></li>";
            }
        }
    }

    // Display admin table
    function displayAdmin() {
        
    // Find the home page ID
        
    $result mysql_query("SELECT value FROM settings WHERE name='homePage'");
        
    $row mysql_fetch_array($result);
        
        
    $homeID $row['value'];
        
        
    // Display a table
        
    $result mysql_query("SELECT id, title, date FROM pages");
        
        echo 
    '<table>';
        echo 
    '<tr>
            <th>ID</th>
            <th>Title</th>
            <th>Date</th>
            <th>Actions</th>
            </tr>'
    ;

        while (
    $row mysql_fetch_array($result)) {
            
    $id $row['id'];
            
    $title $row['title'];
            
    $date date('M d, Y'$row['date']);
            
            echo 
    "<tr>
                <td>
    $id</td>
                <td><a href='"
    BASE_URL "/index.php?id=$id'>$title</a>";
            if (
    $id == $homeID) {
                echo 
    ' <strong>(Home Page)</strong>';
            }
            echo 
    "</td>
                <td>
    $date</td>
                <td><a href='edit.php?id=
    $id'>Edit</a><br />
                <a href='confirm.php?id=
    $id'>Delete</a><br />
                <a href='sethome.php?id=
    $id'>Set as Home</a>";
        }
        echo 
    '</table>';
    }

    // Get array with page IDs
    function getArray() {
        
    $result mysql_query("SELECT id FROM pages");
        
        
    $IDs = array();
        
    $i 0;
        while (
    $row mysql_fetch_array($result)) {
            
    $IDs[$i] = $row['id'];
            
    $i++;
        }
        return 
    $IDs;
    }

    // Admin user login functions

    // Check username and password
    function verifyUser($name$pass) {
        
    // Escape strings
        
    $username mysql_real_escape_string($name);
        
    $password mysql_real_escape_string($pass);

        
    $result mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1");

        if (
    mysql_fetch_array($result)) {
            return 
    true;
        } else {
            return 
    false;
        }
    }

    // Validate user
    function validateUser($name$pass) {
        
    $check verifyUser($namemd5($pass));
        
        if (
    $check) {
            
    $_SESSION['status'] = 'authorized';
            
            
    header('location: index.php');
        } else {
            return 
    'Please enter a correct username and password';
        }
    }

    function 
    logout() {
        if (isset(
    $_SESSION['status'])) {
            unset(
    $_SESSION['status']);

            
    // Remove the cookie
            
    if (isset($_COOKIE[session_name()])) {
                
    setcookie(session_name(), ''time() - 1000);
                
    session_destroy();
            }
        }
    }

    function 
    checkMember() {
        
    session_start();

        if(
    $_SESSION['status'] != 'authorized') {
            
    header('location: login.php');
        }
    }

    ?>
    maby this will show you whats happening?
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,471
    Likes Received:
    199
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Please don't post multiple threads on the same topic. I have removed your other thread.

    See this part in your post above:

    Change localhost to your domain name.
     
  5. Dionoh

    Dionoh Member

    Joined:
    Jan 6, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I did that and still having the same problem.

    config.php

    PHP:
    <?php

    // Database configuration
    define('DB_NAME''dionjo_mycms');
    define('DB_USER''dionjo_member');
    define('DB_PASS''password');
    define('DB_HOST''localhost');
    // Base URL
    define('BASE_URL''http://www.dionjongmans.nl/cms');

    ?>
     
  6. Dionoh

    Dionoh Member

    Joined:
    Jan 6, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    But i think the problems is in this part of the code from functions.php

    PHP:
    <?php

    require_once 'config.php';

    // Connect to MySQL database
    function connect() {
        
    mysql_connectDB_HOSTDB_USERDB_PASS) or die('Connection went wrong. ' mysql_error());
        
    mysql_select_dbDB_NAME) or die('Wrong database. ' mysql_error());
    }
    Correct me if i'm wrong.
     
    #6 Dionoh, Jan 6, 2012
    Last edited: Jan 6, 2012
  7. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,471
    Likes Received:
    199
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    I really can't comment at all on that. Working with a CMS like this is out of the scope of these forums. You'll find better help on the support forums for the CMS you're using.
     
  8. storminternet

    storminternet Well-Known Member

    Joined:
    Nov 2, 2011
    Messages:
    462
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Have you checked database connectivity from any MySQL GUI, like SQLyog etc. To test database connectivity, add your IP in access host from cPanel > Remote MySQL. If database connectivity appears to be working then you need to check scripting. It
    is better if you contact cms support or your host provider.
     
  9. Dionoh

    Dionoh Member

    Joined:
    Jan 6, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    exually i have a big problem. Cause i cannot link a user to my own made database
    Example:

    Database: dionjo_mycms
    DatabaseUser: dionjo_member

    that's the problem.

    and that problem is in my Cpanel.

    I hope that Cpanel can fix this.
    Cause also in my phpMyadmin i cannot edit my database user.

    i hope that Cpanel can help me with this cause i'm missing allot of stuff i think.

    Cpanel please help!!!
     
  10. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,471
    Likes Received:
    199
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Have you spoken with your Host about this problem?
     
  11. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Have you ensured that the MySQL database user has been added to the MySQL database? In cPanel > MySQL Databases area, there are 3 steps for a user to be able to connect to a database. If you miss any of the steps, then you won't be able to connect using that database user to your database.

    Step 1 - Create the database
    Step 2 - Create the database user
    Step 3 - Add the database user to the database

    All 3 are done in cPanel > MySQL databases area. Most times, people perform Steps 1 and 2, but do not add the user to the database in Step 3. It would be in MySQL Databases area at the bottom where it has "Add User To Database" and the "Add" button to do so.
     
  12. ruzbehraja

    ruzbehraja Well-Known Member

    Joined:
    May 19, 2011
    Messages:
    383
    Likes Received:
    7
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator

    Yeah,

    I think you have not done step 3 as infopro suggested too:

    http://forums.cpanel.net/f354/how-reset-my-mysql-password-250992.html#post1041332


    I think the title of this thread should be changed to something more relevant since this is not a mysql password issue.
     
  13. Dionoh

    Dionoh Member

    Joined:
    Jan 6, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    All what has been said is done but still no connection.


    Database Size Users Actions
    dionjo_mycms 0.00 MB dionjo_member Delete User Delete Database
     
  14. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If you still cannot connect and have only cPanel user account access, please contact your hosting provider. If you do have root access to the machine, please open up a ticket with us for us to check database connectivity using WHM > Support Center > Contact cPanel.
     
Loading...

Share This Page