[Warning] Using a password on the command line interface can be insecure. (Solved)

Solution:

Method 1: modify my.cnf configuration file

Edit the/etc/my.cnf configuration file

[ root@localhost local]# vi /etc/my.cnf

Add the following to the configuration file

[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
host = localhost ip        
user = database username
password = 'database password'  

Import and export using the command (specify load profile)

Export database

Mysqldump — defaults extra file =/etc/my.cnf database name > Database name_$ (date +%Y%m%d_%H%M%S).sql

Import database

MySQL — defaults extra file =/etc/my.cnf database name <Database name_$ (date +%Y%m%d_%H%M%S).sql

Method 2: add MySQL environment directly to Linux environment

Edit the/etc/profile configuration file

[ root@localhost local]# vi /etc/profile

Add the following content on the last side, save and exit

export MYSQL_PWD=database password

Make the configuration effective

[ root@localhost local]# source /etc/profile

When you use the mysqldump command to back up the database, you can omit the – P password parameter, and the execution script will not report an error

Mysqldump – H hostname – U username database name > /Usr/local/dbbackup/database name_$ (date +%Y%m%d_%H%M%S).sql

Similar Posts: