Error when trying to use tmpfs for MySQL in Vagrant - mysql

I have a Vagrant machine to run Symfony and it does a lot of interaction with a MySQL database. To try to speed it up a little bit I though about using a tmpfs file system for the data dir.
The data dir is located at /var/lib/mysql, so here's what I tried:
1) stop the mysql service: sudo service mysql stop
2) mount the tmpfs: sudo mount -t tmpfs -o size=512M tmpfs /var/lib/mysql
3) start mysql: sudo service mysql start
And then I get the following error:
Job for mysql.service failed. See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service output is:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit) since Tue 2016-04-05 20:30:52 UTC; 1min 58s ago
Process: 3376 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 3375 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
Process: 3839 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Main PID: 3375 (code=exited, status=0/SUCCESS)
Apr 05 20:30:52 libe systemd[1]: mysql.service holdoff time over, scheduling restart.
Apr 05 20:30:52 libe systemd[1]: start request repeated too quickly for mysql.service
Apr 05 20:30:52 libe systemd[1]: Failed to start MySQL Community Server.
Apr 05 20:30:52 libe systemd[1]: Unit mysql.service entered failed state.
Apr 05 20:30:52 libe systemd[1]: mysql.service failed.
Which doesn't give too much information... Any ideas on how to debug this or what I'm doing wrong? Thanks!

Related

After updating manjaro-system-20210412-1, mysqld.sock is deleted after the system restarts

After I updated manjaro-system-20210412-1 and restarted it, I found that mysqlserver failed to start
➜ ~ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
➜ ~ systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2021-04-20 15:42:18 CST; 23s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 877 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Process: 923 ExecStart=/usr/bin/mysqld $MYSQLD_OPTS (code=exited, status=127)
Main PID: 923 (code=exited, status=127)
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: mysqld.service: Main process exited,
code=exited, status=127/n/a
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: mysqld.service: Failed with result 'exit-
code'.
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: Failed to start MySQL Server.
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: mysqld.service: Scheduled restart job,
restart counter is at 5.
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: Stopped MySQL Server.
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: mysqld.service: Start request repeated too
quickly.
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: mysqld.service: Failed with result 'exit-
code'.
4月 20 15:42:18 ybybwdwd-vmwarevirtualplatform systemd[1]: Failed to start MySQL Server.
➜ ~ systemctl restart mysqld.service
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
Then I found that the files in the /run/mysqld/ directory disappeared. I can't search with sudo find / -name'mysqld.sock'.
I used sudo pacman -Rns mysql to uninstall mysql and reinstall it still reported the above error.
The mysql version is 8.0.23, installed with pacman.
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.

MySQL socket disappeared

I was running a Python script that lasted a few hours and executed insert statements. All locally on Debian. When I came back later to check on the script's status, I was no longer able to log into MySQL.
I had had a command line session going, and this was the message:
A similar message appears when I try to log in or run diagnostic functions like mysqldump. It appears that the socket just got up and walked away. The script and database had been running swimmingly several times before this. The only thing that changed was that I tweaked the script to do a heavier load (processing CSV files), so all can figure is that I ran out of memory and something crashed while I was away.
Trying to restart:
root#debian:/home/user# /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
root#debian:/home/user# /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
failed!
systemctl status mysql.service:
root#debian:/home/user# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled)
Active: activating (start-post) (Result: exit-code) since Fri 2019-02-15 19:26:44 JST; 12s ago
Process: 3324 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
Process: 3317 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 3324 (code=exited, status=2); : 3326 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─3326 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─3373 sleep 1
Feb 15 19:26:44 debian systemd[1]: mysql.service holdoff time over, scheduling restart.
Feb 15 19:26:44 debian systemd[1]: Stopping MySQL Community Server...
Feb 15 19:26:44 debian systemd[1]: Starting MySQL Community Server...
Feb 15 19:26:46 debian systemd[1]: mysql.service: main process exited, code=exited, status=2/INVALIDARGUMENT
journalctl -xn:
Feb 15 19:26:44 debian systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Feb 15 19:26:44 debian systemd[1]: Unit mysql.service entered failed state.
Feb 15 19:26:44 debian systemd[1]: mysql.service holdoff time over, scheduling restart.
Feb 15 19:26:44 debian systemd[1]: Stopping MySQL Community Server...
-- Subject: Unit mysql.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun shutting down.
Feb 15 19:26:44 debian systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Feb 15 19:26:46 debian systemd[1]: mysql.service: main process exited, code=exited, status=2/INVALIDARGUMENT

MySQL server is not starting

When I do:
mysql -u root -p and type my password this is what I get:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
So I type this:
systemctl restart mysql
and I got following error:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
So I did journalctl -xe and got this output:
дек 14 22:57:29 kazak systemd[1]: mysql.service: Failed with result 'exit-code'.
дек 14 22:57:29 kazak systemd[1]: Failed to start MySQL Community Server.
Subject: Unit mysql.service has failed
Defined-By: systemd
Unit mysql.service has failed.
The result is RESULT.
дек 14 22:57:30 kazak systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
дек 14 22:57:30 kazak systemd[1]: mysql.service: Scheduled restart job, restart counter is at 14.
Subject: Automatic restarting of a unit has been scheduled
Defined-By: systemd
So I did this: systemctl status mysql.service And the output is this:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start) since Fri 2018-12-14 22:59:11 +06; 5s ago
Process: 14585 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4037 (code=exited, status=0/SUCCESS); Control PID: 14594 (mysqld)
Tasks: 14 (limit: 4915)
CGroup: /system.slice/mysql.service
├─14594 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
└─14596 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid`
Does anyone knows how to fix, please?

not able to set bind-address=[ip of my server] in mysql

I want to create a master-slave replication on ubuntu servers.
both(master and slave) on different servers.
i made my.cnf(without coments) file on master as:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
bind-address=my_server_ip
server-id=1
log_bin=/var/log/mysql/mysql-bin.log
binlog_do_db=indicators
then i restart using sudo service mysql restart and get the following error:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details
but when i set bind-address=127.0.0.1 it works fine.
below is the reference is used which says bind-address should be the address of master server
https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
but it contadicts with below link which says(under comments section) bind-address is the ip of slave
https://dev.mysql.com/doc/refman/5.7/en/replication-howto-masterbaseconfig.html
systemctl status mysql.service as in above error code
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:
enabled)
Active: activating (start-post) (Result: exit-code) since Sat 2017-11-04
07:12:12 UTC; 11s ago
Process: 25213 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 25205 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
(code=exited, status=0/SUCCESS)
Main PID: 25213 (code=exited, status=1/FAILURE); : 25214 (mysql-
systemd-s)
Tasks: 2
Memory: 400.0K
CPU: 250ms
CGroup: /system.slice/mysql.service
└─control
├─25214 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─25267 sleep 1
Nov 04 07:12:12 fundexpert-test-r systemd[1]: mysql.service: Service hold-
off time over, scheduling restart.
Nov 04 07:12:12 fundexpert-test-r systemd[1]: Stopped MySQL Community
Server.
Nov 04 07:12:12 fundexpert-test-r systemd[1]: Starting MySQL Community
Server...
Nov 04 07:12:14 fundexpert-test-r systemd[1]: mysql.service: Main process
exited, code=exited, status=1/FAILURE
journalctl -xe says:
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Nov 04 07:12:42 fundexpert-test-r systemd[1]: mysql.service: Unit entered
failed state.
Nov 04 07:12:42 fundexpert-test-r systemd[1]: mysql.service: Failed with
result 'exit-code'.
Nov 04 07:12:43 fundexpert-test-r systemd[1]: mysql.service: Service hold-
off time over, scheduling restart.
Nov 04 07:12:43 fundexpert-test-r systemd[1]: Stopped MySQL Community
Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Nov 04 07:12:43 fundexpert-test-r systemd[1]: Starting MySQL Community
Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
below is the reference is used which says bind-address should be the address of master server
No it doesn't. It says 'replace the standard IP address with the IP address of server'. The word 'master' does not appear.
but it contadicts with below link which says(under comments section) bind-address is the ip of slave
No it doesn't. It says 'you will have to make sure that the slave's address or hostname is matched by the bind-address setting'.
You cannot bind to a non-local IP address.

Can't start mysql server

After rebooting server, I can't start mysql again
I received this message:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
I tried journalctl -xe and received this
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Nov 06 21:25:57 myserver systemd[1]: mysql.service: Unit entered failed state.
Nov 06 21:25:57 myserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Nov 06 21:25:57 myserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Nov 06 21:25:57 myserver systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Nov 06 21:25:57 myserver systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Nov 06 21:25:58 myserver systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
here is the result for systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Sun 2016-11-06 21:29:00 UTC; 21s ago
Process: 4563 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 4560 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4563 (code=exited, status=1/FAILURE); : 4566 (mysql-systemd-s)
Tasks: 2
Memory: 320.0K
CPU: 400ms
CGroup: /system.slice/mysql.service
└─control
├─4566 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─4625 sleep 1
Nov 06 21:29:00 myserver systemd[1]: Starting MySQL Community Server...
Nov 06 21:29:01 myserver systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Please help ! Thank you!
I found out the solution after checking mysql error.log
The disk was full.