
how do i change the root password in mysql

import java.sql.*;
class ChangeRootPassword
{
public static void main(String[] args)
{
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String sql = "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('admin')";
Statement stmt = conn.createStatement();
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.