Tag Archives: mysqldump

[Solved] mysqldump Command Error: Got error: 2002: “Can‘t connect to server on ‘127.0.0.1‘ (36)“ when trying to connect

1. When executing mysqldump command for data backup, the error information is as follows:

~ % mysqldump -udbuser -p123456 -h127.0.0.1 school student  > school_student.sql 
mysqldump: Got error: 2002: "Can't connect to server on '127.0.0.1' (36)" when trying to connect

2. Then try the command line to connect to the database, which is also an error

~ % mysql -udbuser -p123456 -h127.0.0.1
ERROR 2002 (HY000): Can't connect to server on '127.0.0.1' (36)

3. After checking the MySQL service result, I remembered that I used ‘mysql. Server start’ to start the database. This cannot follow the system startup. Each time I restart the Mac, I need to run it manually. You can use brew services to start MariaDB   Start the service with the system.

~ % mysql.server start
Starting MariaDB
.211111 16:04:44 mysqld_safe Logging to '/usr/local/var/mysql/xiaokang.err'.
211111 16:04:44 mysqld_safe Starting mariadbd daemon with databases from /usr/local/var/mysql
 SUCCESS! 

4. After successful restart, execute mysqldump again for backup