Solving the problem of \\"Using a password on the command line interface…\\" in MySQL5.6

888u

Last update at :2024-07-03,Edit by888u

Today, when Snail was helping a netizen move his website, he was used to using the mysqldump command when exporting the MySQL database, but an accident occurred\\"Warning: Using a password on the command line interface can be insecure.\\" error message, of course the database must not be backed up. This problem should have appeared in MySQL version 5.6+. It may be a protection mechanism adopted to ensure the security of the database.

If you encounter a problem, go solve it. I probably searched some websites in mainland China. Most of them were copied and the explanations were not clear, so I still looked for information about foreigners, so Snail compiled the more comprehensive ones below. The method has been proven to be flawless.

The first method is to modify the database configuration file

1. We need to modify the database configuration file. This depends on the configuration of our database. Some are in /etc/my.cnf and some are in /etc/my.conf

We need to add the script in the [client] section:

host=localhostuser=database user password=\\’database password\\’

The parameters here need to be modified to our own.

2. Use commands to export and import the database

In fact, at this time, if we use the method introduced in "Detailed explanation of using the mysqldump command to back up and restore MySQL data usage", we can also use it. Although there are still error messages, the database can still be exported. You must be a person who pursues details like a snail, and there should be no problems at all, but we can use the following commands to export and import, and there will be no error prompts.

#Export database

mysqldump –defaults-extra-file=/etc/my.cnf database > database.sql

#Import database

mysql –defaults-extra-file=/etc/my.cnf database < database.sql

Here we can see that the above command is different from the commonly used quick import and import commands. We need to load the MYSQL configuration file we configured. This red part needs to be modified according to our actual path. There will be no error prompts when exporting backup and importing using such commands.

The second method is to use mysql_config_editor

1. Set encryption mode

mysql_config_editor set –login-path=local –host=localhost –user=db_user –password

The red part needs to be changed to our own database user name. After pressing Enter, we will be prompted to enter the database password, so we enter it as usual.

2. Perform backup

mysqldump -u db_user -pInsecurePassword my_database | gzip > backup.tar.gz

Modify the user name and database password based on our data information, and perform a backup. There is still an error message in the snail test here, but the database can be backed up.

In short, as long as we achieve the result, we can choose one of the above two methods. Of course, Snail has also seen other methods, so I won’t share them here. If you are interested, you can search for other solutions.

Recommended site searches: PHP space purchase, Hong Kong server hosting, website registration system, free static space, Ministry of Industry and Information Technology website registration inquiry, Hong Kong virtual host space, how much does it cost to rent a server for a year, registered domain name, PHP space application, website virtual host space,

Solving the problem of \\

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码