Link to home
Create AccountLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

I think I deleted my databases in wamp

I did these 2 commands
('quit' resulted in error response)

update mysql.user set password='password' where user='root'
flush privileges;
quit;


and now I can not find my databases in localhost user root

password change did not work

I log onto mysql workbench with root no password and see two databases
information_schema
test


but my other databases are gone

I do not want to try to install phpmyadmin again because I am using port 81

i can access mysql commandline
C:\wamp\bin\mysql\mysql5.5.20\bin

which .exe do I open




Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd ..

C:\Windows>cd ..

C:\>cd acer
The system cannot find the path specified.

C:\>cd wamp

C:\wamp>cd bin

C:\wamp\bin>cd mysql

C:\wamp\bin\mysql>cd mysql5.5.20

C:\wamp\bin\mysql\mysql5.5.20>cd bin

C:\wamp\bin\mysql\mysql5.5.20\bin>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.00 sec)

mysql> select * from information_schema;
ERROR 1046 (3D000): No database selected
mysql> select * from information_schema;
ERROR 1046 (3D000): No database selected
mysql> use information schema;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'informati
on'
mysql> use test;
Database changed
mysql> show grants;
+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+
1 row in set (0.00 sec)

mysql>

Open in new window

Avatar of arnold
arnold
Flag of United States of America image

You locked yourself out of since the proper way to set password is
Update mysql.user set password=Password('password') where user='root'

You need to start mysql with --skip-grant-tables but on wamp you would follow the following guide to reset the password when the service starts
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

When a password is set, the proper login is mysql -u root -p
You will be prompted for password.
Avatar of rgb192

ASKER

my password change was unsuccessful
note the last two commands
where I can login with
mysql -u root
but not
mysql -u root -p


Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd ..

C:\Windows>cd ..

C:\>cd acer
The system cannot find the path specified.

C:\>cd wamp

C:\wamp>cd bin

C:\wamp\bin>cd mysql

C:\wamp\bin\mysql>cd mysql5.5.20

C:\wamp\bin\mysql\mysql5.5.20>cd bin

C:\wamp\bin\mysql\mysql5.5.20\bin>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.00 sec)

mysql> select * from information_schema;
ERROR 1046 (3D000): No database selected
mysql> select * from information_schema;
ERROR 1046 (3D000): No database selected
mysql> use information schema;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'informati
on'
mysql> use test;
Database changed
mysql> show grants;
+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> exit;
Bye

C:\wamp\bin\mysql\mysql5.5.20\bin>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit;
Bye

C:\wamp\bin\mysql\mysql5.5.20\bin>mysql -u root -p password
Enter password: ********
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y
ES)

C:\wamp\bin\mysql\mysql5.5.20\bin>

Open in new window




http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
(I do not wish to change password, I want to see my databases)
I restarted wamp and restarted the only mysql service (from xampp)

xampp did not properly install and is not running on browser
I think wamp is using the mysql from xampp

I do not want to uninstall xampp because it may delete my mysql databases

User generated image
You need to stop and go through the link arnold gave you.  You have locked out root, and need to re-establish that account to move forward.
Avatar of rgb192

ASKER

http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

I dont understand which to chose
instructions
1
2
or 3
Choose the option for windows. The 1,2,3 are steps to follow.

Create an init file that does
Update mysql.user set password=password('password') where user='root'
Flush privileges
Stop mysql server service.
Then run c:\wamp\bin\mysql\mysql5.2.21\bin\mysqld-nt --init-file=c:\\passwordresetfile.ini

That should do it.
You could also add the --init-file= to the service.
Look where your data files are.
You should use mysql workbench
Avatar of rgb192

ASKER

mysql service is not starting after I run commandline as admin
(but service starts if I click start)
User generated image
this is the notepad++ text file
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;


I also tried
UPDATE mysql.user SET Password='MyNewPass' WHERE User='root';
FLUSH PRIVILEGES;
You are not providing info.
Once you use the init-file method and the service starts, are you able to login using
Mysql -u root -p

The -p is what prompts the user for a password.
Try setting an empty password. '' and see.
Avatar of rgb192

ASKER

mysql -u root -p with blank password logs me in,
but I still cant see my old databases

c:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Open in new window

Note that your original post also allowed root without a password access. The problem is that the temp database allows any connection which is why you were allowed access. running mysql -u someunknownandnevercreateduser
will also grant access to the mysql and the test database.

If you have a blank password, i.e. you reset the init-file removing the password, do not use the -p option.

Could you try the following:
1 net start | find /I "mysql"
2 net stop <entry for the above>
3 c:\wamp\\bin\mysql\mysql5.5.20\bin\mysqld.exe --skip-grant-tables
4 from a different command window run c:\wamp\\bin\mysql\mysql5.5.20\bin\mysql.exe
5 you should have full access to your databases including mysql, use:
select * from mysql.user where user='root'; Make sure to note what you have
6 update mysql.user set password=password('yournewpassword') where user='root' and host='localhost'
7 exit from the mysql client session. tasklist | find /i "mysql".  locate the PID for the mysqld.exe. run taskkill /PID <PID for mysqld>. This will terminate the mysql server.
8 net start <entry from step1>

You should be back up and running. mysql -u root (for empty password) or mysql -u root -p (for a set password.)
Avatar of rgb192

ASKER

c:\xampp\mysql\bin>net start | find /I "mysql"
   mysql
c:\xampp\mysql\bin>net stop mysql
The mysql service is stopping.
The mysql service was stopped successfully.


c:\xampp\mysql\bin>mysqld.exe --skip-grant-tables

Open in new window


I checked the windows service to see that mysql was stopped

but
the last command
mysqld.exe --skip-grant-tables
may not run or takes many minutes to run
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of rgb192

ASKER

mysqld.exe --skip-grant-tables, what happens?

still running
or cmd.exe is frozen
Avatar of rgb192

ASKER

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>net start | find /I "mysql"

C:\Windows\system32>cd c:\xampp\mysql\bin

c:\xampp\mysql\bin>net start | find /I "mysql"

c:\xampp\mysql\bin>net start | find /I "mysql"

c:\xampp\mysql\bin>net stop mysql
The mysql service is not started.

More help is available by typing NET HELPMSG 3521.


c:\xampp\mysql\bin>mysqld.exe --skip-grant-tables
^C
c:\xampp\mysql\bin>mysqld.exe --skip-grant-tables
^C
c:\xampp\mysql\bin>^Z
c:\xampp\mysql\bin>^X

Open in new window



I do ctrl z,x,c

to stop the cmd.exe because
c:\xampp\mysql\bin>mysqld.exe --skip-grant-tables
does not end
Avatar of rgb192

ASKER

part2:

I open a new mysql window and can see my databases
Avatar of rgb192

ASKER

yes, I see all my databases

thank you for teaching me how to log in
so I could get my data back
Avatar of rgb192

ASKER

I opened up another question because I still need to
change (add) a password


https://www.experts-exchange.com/questions/28034165/mysql-change-password-without-locking-root-out.html