Skip to content

Commit cd3019b

Browse files
authored
Merge pull request geerlingguy#273 from andreykaipov/feature/mysql-v8-compatibility
Make the role compatible with MySQL 8
2 parents 3fae14c + 30774a1 commit cd3019b

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

tasks/configure.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
- name: Get MySQL version.
3+
command: 'mysql --version'
4+
register: mysql_cli_version
5+
changed_when: false
6+
27
- name: Copy my.cnf global MySQL configuration.
38
template:
49
src: my.cnf.j2

tasks/secure-installation.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
---
2-
- name: Get MySQL version.
3-
command: 'mysql --version'
4-
register: mysql_cli_version
5-
changed_when: false
6-
72
- name: Ensure default user is present.
83
mysql_user:
94
name: "{{ mysql_user_name }}"
@@ -43,15 +38,15 @@
4338
mysql -u root -NBe
4439
'ALTER USER "{{ mysql_root_username }}"@"{{ item }}" IDENTIFIED WITH mysql_native_password BY "{{ mysql_root_password }}";'
4540
with_items: "{{ mysql_root_hosts.stdout_lines|default([]) }}"
46-
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' in mysql_cli_version.stdout)
41+
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' in mysql_cli_version.stdout or '8.0.' in mysql_cli_version.stdout)
4742

4843
# Set root password for MySQL < 5.7.x.
4944
- name: Update MySQL root password for localhost root account (< 5.7.x).
5045
shell: >
5146
mysql -NBe
5247
'SET PASSWORD FOR "{{ mysql_root_username }}"@"{{ item }}" = PASSWORD("{{ mysql_root_password }}");'
5348
with_items: "{{ mysql_root_hosts.stdout_lines|default([]) }}"
54-
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' not in mysql_cli_version.stdout)
49+
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' not in mysql_cli_version.stdout and '8.0.' not in mysql_cli_version.stdout)
5550

5651
# Has to be after the root password assignment, for idempotency.
5752
- name: Copy .my.cnf file with root password credentials.

templates/my.cnf.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ read_buffer_size = {{ mysql_read_buffer_size }}
8181
read_rnd_buffer_size = {{ mysql_read_rnd_buffer_size }}
8282
myisam_sort_buffer_size = {{ mysql_myisam_sort_buffer_size }}
8383
thread_cache_size = {{ mysql_thread_cache_size }}
84+
{% if '8.0.' not in mysql_cli_version.stdout %}
8485
query_cache_type = {{ mysql_query_cache_type }}
8586
query_cache_size = {{ mysql_query_cache_size }}
8687
query_cache_limit = {{ mysql_query_cache_limit }}
88+
{% endif %}
8789
max_connections = {{ mysql_max_connections }}
8890
tmp_table_size = {{ mysql_tmp_table_size }}
8991
max_heap_table_size = {{ mysql_max_heap_table_size }}
@@ -96,7 +98,7 @@ lower_case_table_names = {{ mysql_lower_case_table_names }}
9698
event_scheduler = {{ mysql_event_scheduler_state }}
9799

98100
# InnoDB settings.
99-
{% if mysql_supports_innodb_large_prefix %}
101+
{% if mysql_supports_innodb_large_prefix and '8.0.' not in mysql_cli_version.stdout %}
100102
innodb_large_prefix = {{ mysql_innodb_large_prefix }}
101103
innodb_file_format = {{ mysql_innodb_file_format }}
102104
{% endif %}

0 commit comments

Comments
 (0)