Home >Database >Mysql Tutorial >Detailed explanation of the problem of backing up data using the mysql command in Linux
In the past few days, the company has launched a new component project, which requires the use of mysql database related technologies. Since I have been using mongodb before, mysql has almost been forgotten, so I can only start again in a Linux virtual machine. study.
Basic addition, deletion, modification and query were fine, but I encountered some problems with data backup. Fortunately, I finally succeeded after some attempts.
The api of Mysql and the backup command mentioned on the Internet are: mysqldump -uroot –p Database name to be backed up > target path/target file name.sql, so I typed it again, but the result was reported A 2002 exception occurred (Additional: When I first used this command, it prompted that mysqldump could not be found. Later, I used a soft link ln to connect the actual address of the mysqldump command to usr/bin):
mysqldump:Got error: 2002: Can't connect to local MySQL server through socket'/tmp/mysql.sock' (2) when trying to connect, 如图1:
After checking the information, I made some modifications, as shown in Figure 2:
But, at this time, 2002 was not available Instead, a 1045 error appeared: mysqldump: Got error: 1045: Access denied for user 'root'@'localhost'(using password: YES) when trying to connect, as shown in Figure 3:
I guess this means there is a problem with the root user and localhost permissions, because I remember that when I set up mysql remote access, I set the host to %, as shown in the figure 4: