Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
liammcdermott opened this issue Dec 8, 2022 · 13 comments

Comments

@liammcdermott
Copy link
Contributor

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
Copy link
Contributor Author

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

@xeonic-ant
Copy link

try to use
mysqld --initialize-insecure

@liammcdermott
Copy link
Contributor Author

liammcdermott commented Dec 13, 2022

@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.

@misilot
Copy link
Contributor

misilot commented Feb 23, 2023

@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 added a commit to misilot/ansible-role-mysql that referenced this issue Feb 23, 2023
Partially Fixes geerlingguy#510

This will create the expected data directory. This most likely does not
address protections in place because of AppArmor on Ubuntu
@misilot
Copy link
Contributor

misilot commented Feb 23, 2023

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 added a commit to misilot/ansible-role-mysql that referenced this issue Apr 18, 2023
Partially Fixes geerlingguy#510

This will create the expected data directory. This most likely does not
address protections in place because of AppArmor on Ubuntu

Have to account for MariaDB and MySQL's differences in initalizing a new
system
misilot added a commit to misilot/ansible-role-mysql that referenced this issue Apr 20, 2023
Partially Fixes geerlingguy#510

This will create the expected data directory. This most likely does not
address protections in place because of AppArmor on Ubuntu

Have to account for MariaDB and MySQL's differences in initalizing a new
system
@github-actions
Copy link

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 github-actions bot added the stale label Jul 15, 2023
@liammcdermott
Copy link
Contributor Author

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

misilot added a commit to misilot/ansible-role-mysql that referenced this issue Jul 18, 2023
Partially Fixes geerlingguy#510

This will create the expected data directory. This most likely does not
address protections in place because of AppArmor on Ubuntu

Have to account for MariaDB and MySQL's differences in initalizing a new
system
@github-actions github-actions bot removed the stale label Jul 22, 2023
@fidanf
Copy link

fidanf commented Jul 24, 2023

Same problem here

Copy link

github-actions bot commented Dec 9, 2023

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 github-actions bot added the stale label Dec 9, 2023
@misilot
Copy link
Contributor

misilot commented Dec 9, 2023 via email

@github-actions github-actions bot removed the stale label Dec 16, 2023
Copy link

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 github-actions bot added the stale label Apr 20, 2024
@liammcdermott
Copy link
Contributor Author

I don't think this is stale

@misilot
Copy link
Contributor

misilot commented Apr 24, 2024

Yeah it’s not stale

@geerlingguy geerlingguy removed the stale label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants