错误 1064 (42000) SQL 语法错误而 运行 ansible 剧本
ERROR 1064 (42000) SQL Syntax error while running ansible playbook
我正在尝试使用 ansible-playbook
将文件加载到 MySQL RDS
tasks:
- name: loadBase
block:
- name: copy loadBase files to target
copy: src=../../myApp/{{ item }}
dest=/tmp/{{ item | basename }}
owner=tomcat group=tomcat mode=0600
with_items: "{{ data.loadBase }}"
- name: load loadBase files into target mysql
shell: mysql -h {{ db_host }} -u root -p{{ db_root_password }} {{ db_name }} < /tmp/{{ item | basename }}
with_items: "{{ data.loadBase }}"
no_log: true
- name: cleanup loadBase files on target
file: path=/tmp/{{ item | basename }}
state=absent
with_items: "{{ data.loadBase }}"
when: loadBase
我正在使用ansible playbook使用的以下配置文件
配置文件:
# data files, relative to the source code root, to be
# conditionally run during a deployment
data:
loadBase:
- data/src/main/sql/structure.sql
- data/src/main/sql/data.sql
- data/src/main/sql/update.sql
我看到 .sql 文件正在从 ansible 服务器添加到应用程序服务器中的 /tmp
文件夹。但是我看到数据没有加载到 MySQL RDS 并且我看到以下错误
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-\nansible_ssh_common_args: '-o ProxyCommand=\"ssh -W %h:%p -q root@bastion-myapp' at line 1",
我正在使用 MySQL RDS 引擎版本 8.0.11。
它正在尝试再次连接到堡垒主机但失败了?
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion-app.org"'
任何帮助,这里有什么问题?
为什么不使用 Ansible MySQL 模块?
见 and https://docs.ansible.com/ansible/2.5/modules/mysql_db_module.html:
# Copy database dump file to remote host and restore it to database 'my_db'
- name: Copy database dump file
copy:
src: dump.sql.bz2
dest: /tmp
- name: Restore database
community.mysql.mysql_db:
name: my_db
state: import
target: /tmp/dump.sql.bz2
我正在尝试使用 ansible-playbook
将文件加载到 MySQL RDS tasks:
- name: loadBase
block:
- name: copy loadBase files to target
copy: src=../../myApp/{{ item }}
dest=/tmp/{{ item | basename }}
owner=tomcat group=tomcat mode=0600
with_items: "{{ data.loadBase }}"
- name: load loadBase files into target mysql
shell: mysql -h {{ db_host }} -u root -p{{ db_root_password }} {{ db_name }} < /tmp/{{ item | basename }}
with_items: "{{ data.loadBase }}"
no_log: true
- name: cleanup loadBase files on target
file: path=/tmp/{{ item | basename }}
state=absent
with_items: "{{ data.loadBase }}"
when: loadBase
我正在使用ansible playbook使用的以下配置文件 配置文件:
# data files, relative to the source code root, to be
# conditionally run during a deployment
data:
loadBase:
- data/src/main/sql/structure.sql
- data/src/main/sql/data.sql
- data/src/main/sql/update.sql
我看到 .sql 文件正在从 ansible 服务器添加到应用程序服务器中的 /tmp
文件夹。但是我看到数据没有加载到 MySQL RDS 并且我看到以下错误
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-\nansible_ssh_common_args: '-o ProxyCommand=\"ssh -W %h:%p -q root@bastion-myapp' at line 1",
我正在使用 MySQL RDS 引擎版本 8.0.11。
它正在尝试再次连接到堡垒主机但失败了?
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion-app.org"'
任何帮助,这里有什么问题?
为什么不使用 Ansible MySQL 模块?
见
# Copy database dump file to remote host and restore it to database 'my_db'
- name: Copy database dump file
copy:
src: dump.sql.bz2
dest: /tmp
- name: Restore database
community.mysql.mysql_db:
name: my_db
state: import
target: /tmp/dump.sql.bz2