Reset mysql root password under Windows or *nix

Windows (mainly copied from Geekpedia)

1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service.

2. Open your MS-DOS command prompt using “cmd” inside the Run window. Inside it navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

3. Execute the following command in the command prompt: mysqld.exe -u root ––skip-grant-tables

4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window.

5. Navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

6. Enter “mysql” and press enter.

7. You should now have the MySQL command prompt working. Type “use mysql;” so that we switch to the “mysql” database.

8. Execute the following command to update the password:

UPDATE user SET Password = PASSWORD(‘NEW_PASSWORD’) WHERE User = ‘root’;

However, you can now run any SQL command that you wish.

After you are finished close the first command prompt and type “exit;” in the second command prompt windows to disconnect successfully. You can now start the MySQL service.

Please note that the 8 step process above can differ depending on the MySQL version you are using, how you configured your server, etc. However, many times you can still easily work around a problem that you experience in any of the steps.

Linux/Unix (mainly copied from ciberciti)

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop

Output:

Stopping MySQL database server: mysqld.
Step # 2: Start to MySQL server w/o password:

# mysqld_safe ––skip-grant-tables &

Output:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Step # 3: Connect to mysql server using mysql client:

# mysql -u root

Output:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>
Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop

Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe –skip-grant-tables
Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

Interesting DOS commands

subst and psubst
A utility to map a subdirectory to a drive letter.
subst subst /D (Deletes the substitute drive)
If SUBST e: c:\edrive were executed, a new drive letter e: would be created, showing the contents of c:\edrive. The opposite can be achieved via the join command.

Another related command is psubst, which is supposedly able to generate permanent map. And visualsubst is a convenient GUI program.

See the rest

Debug Tomcat in Eclipse

1) Modify catalina.bat file to select the right JPDA debug protocol and port, say,
set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=8000
Then, start Tomcat in the debug mode.
catalina.bat jpda start

2) Under Eclipse, select “Run->Debug Configurations…”. Click on “Remote Java Applications”, then click “New”. Type in the title and all. Save and run. Eclipse will connect to the VM that Tomcat is running under.