innobackupex --defaults-file=/etc/my.cnf --user=root --password= xxxxx /backup/20170803 170421 18:15:39 innobackupex: Sta..."/>
溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Xtrabackup備份報(bào)錯(cuò)Failed to connect to MySQL server

發(fā)布時(shí)間:2020-08-05 06:42:28 來(lái)源:ITPUB博客 閱讀:413 作者:feelpurple 欄目:MySQL數(shù)據(jù)庫(kù)
Xtrabackup備份報(bào)錯(cuò)
/backup> innobackupex --defaults-file=/etc/my.cnf --user=root --password='xxxxx' /backup/20170803
170421 18:15:39 innobackupex: Starting the backup operation

IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".

170421 18:15:39  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root'  (using password: YES).
170421 18:15:39  version_check Connected to MySQL server
170421 18:15:39  version_check Executing a version check against the server...
170421 18:15:39  version_check Done.
170421 18:15:39 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: (null)
Failed to connect to MySQL server: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).

仔細(xì)檢查,發(fā)現(xiàn)輸入的用戶名和密碼都是正確的,而且可以正常連接到數(shù)據(jù)庫(kù)
/backup/MySQL_Backup/bin> mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.21-70.1-log Percona Server (GPL), Release 70.1, Revision 698
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>


報(bào)錯(cuò)原因:
在配置文件中沒(méi)有配置socket
Xtrabackup在備份時(shí),會(huì)使用本地的socket連接到數(shù)據(jù)庫(kù)

解決方法:
在配置文件中增加socket選項(xiàng)

[root@localhost bin]# cat /etc/my.cnf
[mysqld]
basedir = /usr
datadir = /var/lib/mysql
log-error = /var/lib/mysql/localhost.localdomain.err
pid-file = /var/lib/mysql/localhost.localdomain.pid
#port = 3306
socket = /var/lib/mysql/mysql.sock

之后重啟數(shù)據(jù)庫(kù),可以正常備份
/backup> innobackupex --defaults-file=/etc/my.cnf --user=backup --password='backup' /backup/20170803
170421 18:34:54 innobackupex: Starting the backup operation

IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".

170421 18:34:54  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/var/lib/mysql/mysql.sock' as 'backup'  (using password: YES).
170421 18:34:54  version_check Connected to MySQL server
170421 18:34:54  version_check Executing a version check against the server...
170421 18:34:54  version_check Done.
170421 18:34:54 Connecting to MySQL server host: localhost, user: backup, password: set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 5.6.21-70.1-log
innobackupex version 2.4.4 based on MySQL server 5.7.13 Linux (x86_64) (revision id: df58cf2)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 32768
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
InnoDB: Number of pools: 1
170421 18:34:54 >> log scanned up to (201239294)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 45 for dmcdbTEST/com_numbering_plan, old maximum was 0
170421 18:34:55 >> log scanned up to (201239294)
170421 18:34:55 [01] Copying ./ibdata1 to /backup/20170803/2017-04-21_18-34-54/ibdata1
170421 18:34:56 >> log scanned up to (201239294)
170421 18:34:57 >> log scanned up to (201239294)
向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI