Resetting MySQL root password
Posted by: tangocharlie (70.103.153.---)
Date: August 21, 2010 08:31AM

I have lost my root MySQL password. I even tried logging in at the command line, can't get in.

I just want to erase and start over, I don't have any data to lose.

I have uninstalled WAMP and deleted everything in c:\wamp, but when I reinstall I'm still locked out of MySQL.

I tried following the reset root password instructions on dev.mysql.com, but it doesn't recognize the command extensions they call for. (http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html)

I'm stumped. How can I just nuke this back to the beginning?

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: stevenmartin99 (109.79.88.---)
Date: August 21, 2010 09:58AM

1. uninstall wamp

2. delete the wamp folder completely

3. reinstall wamp

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 10:20AM

I just installed WAMP.

I already had MySQL installed, so I assume that it won't have overwritten the installation.

Whe I try to connect to phpmyadmin "Tool", it tells me that it can't connect to MySQL.

How do I tell it the root password?

There is precisely ZERO documetation. SO I've been trawling through .ini files setting all "default password" settings to the root password and restarting the wampapache service..

To no avail.

Shouldn't this be very eassy?

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: stevenmartin99 (---.251.255.13.threembb.ie)
Date: August 21, 2010 11:10AM

It is


C:/wamp/apps/phpmyadmin/config.ini.php

Add password and save

Restart wamp and in phpmyadmin error page press "open in new window"

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 12:28PM

OK, got that thanks.

Now, the PHP files in the example code I am running just reference this mysterious file:


Include('../../cfg/db.php');


Any idea where "db.php" should come from or what it's for? I find no references to it in any of the example code I have.

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: stevenmartin99 (109.79.65.---)
Date: August 21, 2010 12:33PM

nope u got a link to the examples?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 12:36PM

[code.google.com]

movies.php

It access that file with no explanation.

I assume that it's supposed to connect to the database.

I have the database set up. It's MySQL. The tables are there.

Just HOW do you tell WAMP to connect? It's a mystery!

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 12:42PM

The PHP admin thing "sees" the database:


Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 01:03PM

I have created that file and put in


mysql_connect('localhost','blah','blah');


It runs now, but the SQL statement fails mysteriously

It has


If (!$rs = mysql_query($sql)) {

Echo '{success:false}';


Ans it sends back that JSON failure packet. Is there really no proper exception structure in PHP explaining WHAT went wrong?

What ELSE do I have to set up to simply have it talk to a database?

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: stevenmartin99 (109.79.65.---)
Date: August 21, 2010 01:08PM

your right they dont have a copy of that file

but most likely ul want to change this

Include('../cfg/db.php');
to just
Include('db.php');

then make a file called "db.php" in c:/wamp/www/


in that file put

<?php
$dbhost = 'localhost';
$dbname = 'learning_ext_js';

$dbuser = 'root';
$dbpass = 'PASSWORD';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
?>


just fill in ur password where PASSWORD is.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: stevenmartin99 (109.79.65.---)
Date: August 21, 2010 01:12PM

of course u can get errors but you need to ask for them...

for mysql_query you would use

$rs = mysql_query($sql); 

if (!$rs) {
    die('Invalid query: ' . mysql_error());

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 08/21/2010 01:14PM by stevenmartin99.

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 01:23PM

Thanks for your help. It's croaked into life for me, and I can get some JSON back!

I will continue hacking with it!

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 02:11PM

How do I access the result of a INSERT?



$sql = "INSERT INTO movies (id,title,director,genre,tagline) VALUES (0,'".$_REQUEST['title']."','',0,'')";
$rs = mysql_query($sql)

And $rs is just the boolean value TRUE

Shouldn't it return the inserted row? Or at least the row ID?

How can we know what got inserted?

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: stevenmartin99 (109.79.65.---)
Date: August 21, 2010 02:37PM

u shud know already.. as u inserted the data

VALUES (0,'".$_REQUEST['title']."','',0,'')";



if u got true... it went in

ul need to add a column in the db (auto increment) and use that as an id number-- check the next id number before inserting and then select that row after inserting..

or just check ur values before u send them ...

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 03:00PM

It's auto-creating that id field. How do I find the ID?

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: stevenmartin99 (109.79.65.---)
Date: August 21, 2010 03:13PM

use LAST_INSERT_ID()

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 03:48PM

that will be last id inserted into what table?

Also, how do I decode a JSON parameter?

I am passed

{"id":0,"title":"New Movie","director":"Agg Agg","runtime":88,"genre":"1","tagline":"oppo","released":"2010-08-21T00:00:00"}

I need that decoded into an object (I guess you PHP guys call them "arrays", but for me they are NUMERICALLY indexed) in which each property is named as the JSON property, and the values are decoded appropriately.

ie, that ISO date to be a date which can be inserted into the "released" row of that table.

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 04:03PM

OK, I see json_decode, but passing that JSON string results in a "thing" that I can't seem to use as a regular PHP object/array

I use

        $rec = json_decode($_REQUEST['data']);
        $sql = "INSERT INTO movies (id,title,director,runtime,released,genre,tagline) VALUES (".
            "0,".
            "'".$rec['title']."',".
            "'".$rec['director']."',".
            $rec['runtime'].",".
            $rec['released'].",".
            $rec['genre'].",".
            "'".$rec['tagline']."'".
        "winking smiley";

and It throws

Cannot use object of type stdClass as array in <b>C:\wamp\www\LearningExtJS\rewrites\chap1-7_Code\Chapter6\movies-sync.php</b> on line <b>1



Edited 1 time(s). Last edit at 08/21/2010 04:04PM by Animal.

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 04:22PM

OK, I got as far as


        $rec = json_decode($_REQUEST['data'], true);
        $sql = "INSERT INTO movies (id,title,director,runtime,released,genre,tagline) VALUES (".
            "0,".
            "'".$rec['title']."',".
            "'".$rec['director']."',".
            $rec['runtime'].",".
            "'".date_create_from_format("Y-m-d\TH:i:s", $rec['released']).format("Y-m-d"winking smiley."',".
            $rec['genre'].",".
            "'".$rec['tagline']."'".
        "winking smiley";

So it can loop through the decoded object.

But how do I massage the date into a format that SQL likes?

Options: ReplyQuote
Re: Resetting MySQL root password
Posted by: Animal (---.range86-137.btcentralplus.com)
Date: August 21, 2010 04:49PM

I have found the incantation


        $rec = json_decode($_REQUEST['data'], true);
        $rel = date_format(date_create_from_format("Y-m-d\TH:i:s", $rec['released']), "Y-m-d"winking smiley;
        $sql = "INSERT INTO movies (id,title,director,released,runtime,genre,tagline) VALUES (".
            "0,".
            "'".$rec['title']."',".
            "'".$rec['director']."',".
            "'".$rel."',".
            $rec['runtime'].",".
            $rec['genre'].",".
            "'".$rec['tagline']."'".
        "winking smiley";


Options: ReplyQuote


Sorry, only registered users may post in this forum.