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:
- [Solved] Backup mysql8.0 with the mysqldump of mysql5.7 Error
- Mysqldump backup problems got error: 1045, error 1045 (28000), got error: 1449
- How to Backup MySQL database regularly
- When installing MySQL database on MAC, the system prompts MySQL: command not found
- When installing MySQL database on Mac OS, the system prompts MySQL: command not found
- [Mac Error]-bash: mysql: command not found
- How to Sovle mysqldump backup Error on the MySQL command line
- mysqldump unknown table ‘column_statistics’
- Mac ADB prompts command not found
- HDFS Operate hadoop Error: Command not Found [How to Solve]