int get_root_password()
{
  int res;
  fprintf(stdout, "\n\n\n"
		  "NOTE: RUNNING ALL THE STEPS FOLLOWING THIS IS RECOMMENDED\n"
		  "FOR ALL MySQL SERVERS IN PRODUCTION USE!  PLEASE READ EACH\n"
		  "STEP CAREFULLY!\n\n\n\n\n");
  if (!password_provided)
  {
    fprintf(stdout, "In order to log into MySQL to secure it, we'll need the\n"
		    "current password for the root user. If you've just installed"
		    "\nMySQL, and you haven't set the root password yet, the \n"
		    "password will be blank, so you should just press enter here."
		    "\n\n");
    password= get_tty_password(NullS);
  }
  if (!mysql_real_connect(&mysql, opt_host, opt_user,
			  password, "", opt_port, opt_mysql_unix_port, 0))
  {
    if (mysql_errno(&mysql) == ER_MUST_CHANGE_PASSWORD_LOGIN)
    {
      bool can= TRUE;
      mysql_options(&mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, &can);
      if (!mysql_real_connect(&mysql, opt_host, opt_user,
                              password, "", opt_port, opt_mysql_unix_port, 0))
      {
	fprintf(stdout, "Error: %s\n", mysql_error(&mysql));
	free_resources();
	exit(1);
      }
      fprintf(stdout, "\nThe existing password for the user account has "
	              "expired. Please set a new password.\n");
      set_root_password(0);
    }
    else
    {
      fprintf(stdout, "Error: %s\n", mysql_error(&mysql));
      free_resources();
      exit(1);
    }
  }
  fprintf(stdout, "\n\nOK, successfully used password, moving on...\n\n");
  res= (password[0] != '\0') ? 1 : 0;
  return(res);
}
int get_root_password()
{
  int res;
  fprintf(stdout, "\n\n\n"
		  "NOTE: RUNNING ALL THE STEPS FOLLOWING THIS IS RECOMMENDED\n"
		  "FOR ALL MySQL SERVERS IN PRODUCTION USE!  PLEASE READ EACH\n"
		  "STEP CAREFULLY!\n\n\n\n\n");
  if (!password_provided)
  {
    fprintf(stdout, "In order to log into MySQL to secure it, we'll need the\n"
		    "current password for the root user. If you've just installed"
		    "\nMySQL, and you haven't set the root password yet, the \n"
		    "password will be blank, so you should just press enter here."
		    "\n\n");
    password= get_tty_password(NullS);
  }
  if (!mysql_real_connect(&mysql, opt_host, opt_user,
			  password, "", opt_port, opt_mysql_unix_port, 0))
  {
    if (mysql_errno(&mysql) == ER_MUST_CHANGE_PASSWORD_LOGIN)
    {
      bool can= TRUE;
      mysql_options(&mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, &can);
      if (!mysql_real_connect(&mysql, opt_host, opt_user,
                              password, "", opt_port, opt_mysql_unix_port, 0))
      {
	fprintf(stdout, "Error: %s\n", mysql_error(&mysql));
	free_resources();
	exit(1);
      }
      fprintf(stdout, "\nThe existing password for the user account has "
	              "expired. Please set a new password.\n");
      set_root_password(0);
    }
    else
    {
      fprintf(stdout, "Error: %s\n", mysql_error(&mysql));
      free_resources();
      exit(1);
    }
  }
  fprintf(stdout, "\n\nOK, successfully used password, moving on...\n\n");
  res= (password[0] != '\0') ? 1 : 0;
  return(res);
}