ansible-role-mysql icon indicating copy to clipboard operation
ansible-role-mysql copied to clipboard

MySQL fails to start when `mysql_datadir` is set to anything other than MySQL's default

Open liammcdermott opened this issue 2 years ago • 15 comments

Our Ansible playbooks use this role and set the MySQL datadir like this:

mysql_datadir: /data/mysql

When this is set the plays fail with this error on every database server:

fatal: [db05]: FAILED! => {"changed": false, "msg": "Unable to start service mysql: Job for mysql.service failed because the control process exited with error code.\nSee \"systemctl status mysql.service\" and \"journalctl -xeu mysql.service\" for details.\n"}

Then running sudo journalctl -xeu mysql turns up the following:

mysql-systemd-start[450456]: MySQL system database not found in /data/mysql. Please run mysqld --initialize

Unfortunately, running mysqld --initialize appears to work, but causes plays to fail at a later step with a MySQL permissions error. So it's not a viable workaround.

This issue is a duplicate of #399 , the bot closed it, despite it being a current issue.

OS: Ubuntu 22.04 MySQL version: /usr/sbin/mysqld Ver 8.0.31-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

liammcdermott avatar Dec 08 '22 18:12 liammcdermott

Note: I have a task to disable AppArmor for MySQL, so that's probably not the cause.

liammcdermott avatar Dec 08 '22 18:12 liammcdermott

try to use mysqld --initialize-insecure

xeonic-ant avatar Dec 12 '22 10:12 xeonic-ant

@xeonic-ant Ah, thanks! I found another workaround (symlinking /var/lib/mysql/data/mysql), but if I hadn't I'd definitely give that a try.

Just want to note: even with a workaround, this role professes support for changing the datadir, so it should work.

liammcdermott avatar Dec 13 '22 17:12 liammcdermott

@geerlingguy any suggestions on what to do? I am running into this trying to setup a new server on Ubuntu 22.04.

We disable / mask apparmor, so it isn't apparmor stopping it.

My settings


mysql_root_username: root
mysql_root_password: password
mysql_port: 3306

mysql_datadir: "/klib/data/mysql"
mysql_root_password_update: true

This is the error log after a fresh install and run of the playbook.

2023-02-23T16:30:26.338343Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.22.04.2) starting as process 14533
2023-02-23T16:30:26.354926Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-23T16:30:26.913776Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-23T16:30:27.243003Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-02-23T16:30:27.243049Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-02-23T16:30:27.251935Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2023-02-23T16:30:27.302556Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2023-02-23T16:30:27.302611Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32-0ubuntu0.22.04.2'  socket: '/tmp/tmp.wg18ZQFT1Q/mysqld.sock'  port: 0  (Ubuntu).
2023-02-23T16:30:27.352552Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.32-0ubuntu0.22.04.2).
2023-02-23T16:30:28.797435Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32-0ubuntu0.22.04.2)  (Ubuntu).
2023-02-23T16:30:29.739675Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.22.04.2) starting as process 14604
2023-02-23T16:30:29.747078Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-23T16:30:29.977136Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-23T16:30:30.208167Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-02-23T16:30:30.208219Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-02-23T16:30:30.215713Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2023-02-23T16:30:30.242733Z 7 [System] [MY-013172] [Server] Received SHUTDOWN from user boot. Shutting down mysqld (Version: 8.0.32-0ubuntu0.22.04.2).
2023-02-23T16:30:30.248421Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2023-02-23T16:30:31.778579Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32-0ubuntu0.22.04.2)  (Ubuntu).

misilot avatar Feb 23 '23 16:02 misilot

I made a PR that will initialize a custom data directory. This does not handle any AppArmor issues, since we made the decision at this point to disable AppArmor locally.

misilot avatar Feb 23 '23 17:02 misilot

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] avatar Jul 15 '23 20:07 github-actions[bot]

I don't see anything in the commit logs to suggest this is fixed, so don't mark it stale yet, bot 👍

liammcdermott avatar Jul 17 '23 13:07 liammcdermott

Same problem here

fidanf avatar Jul 24 '23 20:07 fidanf

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] avatar Dec 09 '23 20:12 github-actions[bot]

not stle

On Sat, Dec 9, 2023 at 2:58 PM github-actions[bot] @.***> wrote:

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories to see the reasons why I mark issues as stale.

— Reply to this email directly, view it on GitHub https://github.com/geerlingguy/ansible-role-mysql/issues/510#issuecomment-1848680909, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALBHSFNQAEAK2IRDGIBOB3YITGGTAVCNFSM6AAAAAASYO5MP2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBYGY4DAOJQHE . You are receiving this because you commented.Message ID: @.***>

misilot avatar Dec 09 '23 20:12 misilot

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] avatar Apr 20 '24 20:04 github-actions[bot]

I don't think this is stale

liammcdermott avatar Apr 24 '24 05:04 liammcdermott

Yeah it’s not stale

misilot avatar Apr 24 '24 11:04 misilot

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] avatar Aug 24 '24 20:08 github-actions[bot]

Not staleOn Aug 24, 2024, at 3:58 PM, github-actions[bot] @.***> wrote: This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! Please read this blog post to see the reasons why I mark issues as stale.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

misilot avatar Aug 24 '24 22:08 misilot