Tag Archives: password

Mongodb java version 3.X, prompt “XXX (an encryption algorithm) is not available” when there is a user name and password

First of all, describe the project environment: Maven + mongodb-java-driver-3.2.2

The original project was written with Mongo 2. X driver, and then upgraded to 3. X. The first big change is user name and password verification.

This is the way to get mongoclient.


import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;

/**
 * MongoDBUtils
 * @author administration
 *
 */
public class DBUtil {

	/**
	 * Connect to mongoDB with username password (MongoCredential method)
	 * @param mongodbAddr
	 * @param databaseName
	 * @return
	 */
	public static MongoClient getMongoClientByCredent(String mongodbAddr, String databaseName){
		MongoClient mongoClient;
		Properties p = TDTFile.getProperAddr("db.properties");
		String user = p.getProperty("username");
		String pswd = p.getProperty("password");
		List<ServerAddress> serverAddrList = new ArrayList<ServerAddress>();
		ServerAddress serverAddress = new ServerAddress(mongodbAddr);
		serverAddrList.add(serverAddress);
		List<MongoCredential> credentialList = new ArrayList<MongoCredential>();
		MongoCredential credential = MongoCredential.createCredential(user, databaseName, pswd.toCharArray());
		credentialList.add(credential);
		mongoClient = new MongoClient(serverAddrList, credentialList);
		return mongoClient;
	}
	
	/**
	 * Connect to mongoDB with username password (URI method)
	 * @param mongodbAddr
	 * @param databaseName
	 * @return
	 */
	public static MongoClient getMongoClientByURI(String mongodbAddr, String databaseName){
		MongoClient mongoClient;
		Properties p = TDTFile.getProperAddr("db.properties");
		String user = p.getProperty("username");
		String pswd = p.getProperty("password");
		//System.out.println(user + "," + pswd);
		String uri = String.format("mongodb://%s:%s@%s/%s", user, pswd, mongodbAddr, databaseName);
		System.out.println(uri);
		MongoClientURI mongoClientURI = new MongoClientURI(uri);
		mongoClient = new MongoClient(mongoClientURI);
		return mongoClient;
	}
	
}

Two ways are no problem, run well in eclipse. But!! After packaging with MVN package, it can’t be used. After a night and a day’s analysis, I locked the root cause of the error in the statement that the command line executed the command. My sentence is like this:

java -Djava.ext.dirs=../lib Other parameters

The problem lies in the – D parameter. Baidu knows that – D is equivalent to setting external environment variables. Since my main method relies on many third-party jar packages, it seems that there is nothing wrong with it. But it ignores a problem, that is

After using the – D parameter to specify other directories, Java needs to load% Java_ The jar package in the home% \ JRE/lib/ext directory is no longer loaded!! I searched the usage of – D parameter on the Internet for a long time, but no one mentioned it.. But it’s hard for me. One day is wasted here..

 

Solution:

Package the required external dependent packages, including some packages such as JDK’s own encryption algorithm, into lib with Maven. Problem solving. By the way, the algorithm package required by mongodb3. X is% Java_ HOME%\jre\lib\ext\sunjce_ provider.jar

 

Error 1045 (28000): solution to access denied for user ‘root’ @’localhost ‘(using password: no)


This problem was encountered when installing MySQL service under Windows, which was installed with MySQL green version. After installation, when connecting to MySQL service, enter the command “mysql-uroot-p”. Because the password was not set for the first login, the error message was as follows:
“ERROR 1045 (28000): Access Denied for user ‘root’@’localhost’ (using password: NO)”

The diagram below:

Solutions:
First you need to turn off the MySQL service and enter the command:
mysql> net stop MySQL
To start the local MySQL service in safe mode (note: launch the CMD window as an administrator), enter the command “MySQld — Defaults file=”G:\Install_Applications\ mysql.8.0.11 \ My.ini” –console –skip-grant — tables “to start the MySQL service, the cursor will stop without any output, which indicates that the MySQL service has been started.

Start the CMD window, and enter the command “mysql-uroot-p” to directly enter and log in to the mysql server, and then modify, you can enter the command:
(before 5.7.11) & GT; update user set password=password(“123456″) where user=”root”;

(5.7.11 or later) & GT; update user set authentication_string=password(“123456″) where user=”root”;
Here I’m using:
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘HuaZai12345! ‘;
The diagram below:

Now exit, enter the command “mysql-uroot-p” and enter the password just set, and you can log in to the mysql server normally, as shown in the figure below:

Ok, this is the solution for ERROR 1045 (28000): Access Denied for user ‘root’@’localhost’ (using password: NO). If you have any questions, please feel free to leave me a message.

: “learn together, make progress together”, I also hope that we will pay more attention to the IT community of CSND.

ERROR: You must wait longer to change your password passwd: Authentication token manipulation error

Linux users encountered an error message when changing their passwords:

[monitor@monitor1 etc]$ passwd
Changing password for user monitor.
Changing password for monitor
(current) UNIX password:
You must wait longer to change your password
passwd: Authentication token manipulation error
Linux Version: Red Hat EnterpriseLinux Server Release 5.7 (Tikanga)

Fix: Linux has a limit on the amount of time you can change your password again. If the number of days is 5, the user in Linux cannot change his password for 5 days. You can change this setting in the /etc/shadow file: the fourth field is the number of days it will take to change the password again.

Passwd: authentication token manipulation error in Linux

If in Linux, whether root or ordinary user logs in and changes their password, passwd: Authenticationtoken Manipulation error occurs — the solution to the error:
Root herself failed to change the password

Normal user failed to change password

1. Reporting such an error is: password: authentication token operation error, usually due to the permissions of the password file, but may also be the root directory space is full.

Using the Lsattr command to view the file properties that hold the user and password, you find the I option: (I: Do not arbitrarily change files or directories.) As a result, all users cannot change their passwords because they have no permission to do so.
2. We need to use the chattr command to revoke the I permission, and then modify, it is ok.

3. Then test root and Xiaogang users to change their passwords.
Test the root user to change the password

Test xiaogang users to change their passwords

4. For security reasons, it is better to change the password and protect the file where the user and password are stored.
Also chattr + I /etc/passwd and chattr + I /etc/shadow files
5 ordinary users to modify their passwords, is required, the password must be complex, and in the password dictionary some characters can be set.

MySQL error — multiple methods of failed to find valid data directory and MySQL setting password appear

MYSQL error – Failed to find valid data directory

operating environment: windows10

database version: mysql.8.0.16

problem description:

MySQL service is starting.
MySQL service cannot start. The
service did not report any errors.

solution:

  • manually empty the files in the data folder under the installation path (possibly due to incomplete files due to previous initialization failure)
  • into the bin path remove mysql service
  • under the bin path enter mysqld –initialize-insecure (the program will create many files under the data folder)
  • continue to enter mysqld -install (service has been reinstalled)
  • start mysql service, enter net start mysql

the MYSQL error, Failed to find valid data directory. _Nikita – _failed CSDN blog to find valid data directory.
https://blog.csdn.net/Hellen0708/article/details/93377724

=================================================================================

=================================================================================

=================================================================================

the mysql database password _qq_26486949 blog blog – CSDN _mysql password
https://blog.csdn.net/qq_26486949/article/details/88373487

mysql database password Settings

mysql newly installed does not have a password by default, so it needs to be set manually.

method 1: use the SET PASSWORD command

log in to MySQL first.

format: mysql> Set password for username @localhost = password(‘ new password ‘);

example: mysql> set password for root@localhost = password(‘123’);

method 2: mysqladmin

format: mysqladmin-u username -p old password password new password

example: mysqladmin-uroot-p123456 password 123

method 3: edit user table

directly with UPDATE

log in to MySQL first.

mysql> use mysql;

mysql> update user set password=password(‘123′) where user=’root’ and host=’localhost’;

mysql> flush privileges;

method 4: use the GRANT statement mysql> Grant all on *.* to ‘root’@’localhost’ IDENTIFIED BY ‘your password ‘with grant option; mysql> flush privileges;

method 5: when you forget the root password or initialize the password, you can do this:

Take Windows as an example:

1. Close the running MySQL service.
2. Open a DOS window and go to mysql\bin directory.

3. Enter mysqld –skip-grant-tables enter. Skip-grant-tables means to skip permission table authentication when starting MySQL service.

4. Open another DOS window (because the DOS window is no longer active) and go to the mysql\bin directory.
5. Enter mysql enter. If successful, mysql prompt &gt will appear. .

6. Connection permission database: use mysql; .

. Update user set password=password(“123″) where user=”root”; Don’t forget to put a semicolon at the end.

if ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’ occurs, this is because the password field is no longer available in mysql database in version 5.7, and the password field is changed to authentication_string. The statement should be update User Set Authentication_string =password(“123″) where user=”root”;

7. Flush privileges (mandatory step) : flush privileges; .

8. Quit quit.
9. Log out of the system, enter again, log in with the username root and the new password 123 that you just set.