I need to install a MySQL server as a dependency.
Whenever I use:
sudo apt-get update
sudo apt-get install -y mysql-server
sudo service mysql start
It starts it and tells me the pid, but then just hangs there. Any suggestions?
I need to install a MySQL server as a dependency.
Whenever I use:
sudo apt-get update
sudo apt-get install -y mysql-server
sudo service mysql start
It starts it and tells me the pid, but then just hangs there. Any suggestions?
I just banged on this for 20 minutes and get the same result, it hangs on âmysqld is running as pid 4621â and eventually leads to timeout. My gut feeling is this use case might need to wait for custom container rollout.
Fwiw I have pgsql running just fine with the following setup script:
#!/usr/bin/env bash
set -euo pipefail
apt-get update -qq
apt-get install -yqq postgresql
pg_ctlcluster --skip-systemctl-redirect 16 main start
su - postgres -c "createuser -s $(whoami)"
Hope this helps!
Interesting, thanks @swombat!
Prior to getting it to work, did you have a similar issue to what @knavillus and I describe when we try to get MySQL working? Ie, was it hanging on the pid? Or did it just work on your first try?
Mine hung up on the pid, I was trying to do what @swombat did, but didnât have the chops :). Nice work. Here is my test of this on the environment setup, works great!
And when I fired off this task:
This repo is empty, and you donât need to add any code. For this task we are testing the postgres implementation. Please use:
createdb -U (whoami) (whoami)
psql -U $(whoami)and the create a table:
CREATE TABLE test_table(id SERIAL PRIMARY KEY, name TEXT);
INSERT INTO test_table(name) VALUES (âhelloâ);
SELECT * FROM test_table;Report back with results to see if you can interact with the DB
Very cool!
Shame my app is pretty dependent on MySQL and that I canât use Postgres
OK, hacked at it some more (thankyou o3 for the assist). Let me know if this gets you rollingâŚ
Codex Task
#!/usr/bin/env bash
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
# 1. Install the minimal binaries
apt-get update -qq
apt-get install -yqq --no-install-recommends \
mysql-server-core-8.0 mysql-client-core-8.0 passwd
# 2. Ensure the mysql system account exists
if ! id -u mysql >/dev/null 2>&1; then
groupadd --system mysql
useradd --system --gid mysql --home /nonexistent \
--shell /usr/sbin/nologin mysql
fi
# 3. Data directories **and** secure-file-priv directory
mkdir -p /var/lib/mysql \
/var/lib/mysql-files \
/var/run/mysqld
chown -R mysql:mysql /var/lib/mysql /var/lib/mysql-files /var/run/mysqld
chmod 750 /var/lib/mysql-files # MySQL expects owner-only access:contentReference[oaicite:1]{index=1}
# 4. Initialise and start detached
mysqld --initialize-insecure --user=mysql # empty root pwd:contentReference[oaicite:2]{index=2}
mysqld --daemonize --user=mysql \
--socket=/var/run/mysqld/mysqld.sock \
--pid-file=/var/run/mysqld/mysqld.pid
# 5. Wait until the server is ready
until mysqladmin --socket=/var/run/mysqld/mysqld.sock ping --silent; do sleep 1; done
#verify
# Should print exactly one mysqld line
ps -fp $(cat /var/run/mysqld/mysqld.pid)
# Fast âis it alive?â check
mysqladmin --socket=/var/run/mysqld/mysqld.sock ping
# â mysqld is alive
# A few server counters & compile flags
mysqladmin --socket=/var/run/mysqld/mysqld.sock version
Wow, that totally worked â THANK YOU!
I did not have those issues. I asked ChatGPT (!) what to install to get postgres working, it suggested these packages and commands, I thought, yeah ok that makes sense, I tried, it worked.
In case it helps someone else in the future, MariaDB seems to install right off the bat without any extra stuff. So if your app is compatible or depends on that, itâs pretty straight forward.
# Install MariaDB
sudo apt-get install -y mariadb-server
# Start MariaDB using service instead of systemd
sudo service mariadb start
# Check MariaDB version
mariadb --version
Thanks so much! Youâre the type of user we want to see more around here!
Iâd welcome you to the community, but it seems youâve been around a while now!
Seriously, though, thanks for helping out. Itâs appreciated.
I donât know how many times a Google search for an arcane problem has saved me in the past, so hopefully this helps someone in the future.