MySQL general_log cannot be enabled. What am I doing wrong? - mysql

I'm on Ubuntu 18.04 with MySQL 5.7.24 and I'm trying to enable the general_log as described here.
So in my /etc/mysql/my.cnf I added this:
general_log = on
general_log_file=/tmp/mysql.log
I then stopped and started mysql again, but I get an error:
$ sudo service mysql stop
$ sudo service mysql start
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 checked out systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2019-01-04 17:50:31 CET; 45s ago
Process: 27206 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
Process: 27613 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Main PID: 27208 (code=exited, status=0/SUCCESS)
Jan 04 17:50:31 librem systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 04 17:50:31 librem systemd[1]: Failed to start MySQL Community Server.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jan 04 17:50:31 librem systemd[1]: Stopped MySQL Community Server.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Start request repeated too quickly.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 04 17:50:31 librem systemd[1]: Failed to start MySQL Community Server.
In journalctl -xe I get pretty much the same.
I tried creating the log file in /tmp/mysql.log and chmodding it to 777, but after doing that, starting up mysql fails with the same errors.
Does anybody know what's wrong here?

In the end I solved it using this tip. Just copy pasting it here for future readers:
SET global log_output = 'FILE';
SET global general_log_file='/var/log/mysql/general.log';
SET global general_log = 1;
No need to restart. The user does need the SUPER privilege (GRANT SUPER ON *.* TO user1#localhost). This works for existing and new connections on the DB and is a global setting so it works for all databases.
It can be turned off with
SET global general_log = 0;

Related

ERROR 2006 (HY000): MySQL server has gone away & conflict with max_allowed_packet

I wanted to import a sql dump
mysql -u username mydb < file.sql
And of course i get the classic ERROR 2006 (HY000) at line 1701: MySQL server has gone away message. No big deal i know that i need to increase the packet size. So i edit the /etc/mysql/mysql.cnf file and add the line max_allowed_packet=64M. But when i try to start the mysql server i get an error.
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-01-21 16:27:47 CET; 15s ago
Process: 9151 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 9112 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 27620 (code=exited, status=0/SUCCESS)
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jan 21 16:27:47 aleksandar-pc systemd[1]: Stopped MySQL Community Server.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Start request repeated too quickly.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Failed with result 'exit-code'.
If i remove the code added for packets, the server can be started normally.
Can anyone help me with this, i really need to import this large db and don't know how to fix this mysql error.
Mysql verison: Ver 14.14 Distrib 5.7.25, for Linux (x86_64)
Linux: Ubuntu 18.04 LTS
Ok i forgot this [mysqld] above:
[mysqld]
max_allowed_packet=128M

MySQL Galera cluster can't initiate first node

I'm using Ubuntu 16.04 and installed MySQL version 5.7 via apt-get in AWS.
After that, I've managed to upgrade the MySQL to Galera Cluster by following the Documentation from the official website using apt-get install galera-3 galera-arbitrator-3 mysql-wsrep-5.6
After that I've configured the file /etc/mysql/conf.d/galera.cnf to be:
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="test_cluster"
wsrep_cluster_address="gcomm://this_node_ip,second_ip,third_ip"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="this_node_ip"
wsrep_node_name="this_node_name"
The step above is repeated for the other 2 nodes (with it's own IP address). And stop the mysql with the following command sudo service mysql stop for each of the node.
And in the first node, I'm trying to start with the following command:
sudo service mysql start --wsrep-new-cluster
But it returns: Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
In the systemctl status mysql.service, it says:
● mysql.service - LSB: start and stop MySQL
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2018-02-09 15:53:16 +08; 33s ago
Docs: man:systemd-sysv-generator(8)
Process: 6264 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
Feb 09 15:53:15 systemd[1]: Starting LSB: start and stop MySQL...
Feb 09 15:53:15 mysql[6264]: Starting MySQL
Feb 09 15:53:15 mysql[6264]: .180209 15:53:15 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
Feb 09 15:53:15 mysql[6264]: 180209 15:53:15 mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
Feb 09 15:53:16 mysql[6264]: * The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
Feb 09 15:53:16 systemd[1]: mysql.service: Control process exited, code=exited status=1
Feb 09 15:53:16 systemd[1]: Failed to start LSB: start and stop MySQL.
Feb 09 15:53:16 systemd[1]: mysql.service: Unit entered failed state.
Feb 09 15:53:16 systemd[1]: mysql.service: Failed with result 'exit-code'.
Hope these information helps.

Webmin MySQL Error on starting

Firstly, I must say that I have not used these tools in the past so linux commands are not familiar to me.
Backstory:
On my Webmin server, I have been trying to get a Drupal Installation to work. I changed a parameter on the MySQL module and now the MySQL will not start.
Current Situation:
When I click "Start MySQL Server" I receive the follow:
Failed to start database : Redirecting to /bin/systemctl start
mariadb.service Job for mariadb.service failed because the control
process exited with error code. See "systemctl status mariadb.service"
and "journalctl -xe" for details.
I've search around this, and most people recommend to reinstall MariaDB.
I connected to the server with putty to get some more information
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2017-08-01 16:29:00 UTC; 7min ago
Process: 22851 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
Process: 22850 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
Process: 22823 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 22850 (code=exited, status=0/SUCCESS)
Aug 01 16:28:57 li172-89.members.linode.com systemd[1]: Starting MariaDB database server...
Aug 01 16:28:57 li172-89.members.linode.com mysqld_safe[22850]: 170801 16:28:57 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Aug 01 16:28:57 li172-89.members.linode.com mysqld_safe[22850]: 170801 16:28:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: mariadb.service: control process exited, code=exited status=1
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: Failed to start MariaDB database server.
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: Unit mariadb.service entered failed state.
Aug 01 16:29:00 li172-89.members.linode.com systemd[1]: mariadb.service failed.
[root#li172-89 ~]#
I gather that this means Mariadb wont even start so I should probably reinstall it. I did try to simply use a defaul my.cnf but that didn't really do anything.
Ideally, I do not want to lose any of the databases I have.
What should I do? Should I reinstall Mariadb? Is there a suitable guide that lists the commands? Could I install Mariadb but to another folder?
What is the best course of action at this point?

Mysql Error ERROR 2002 (HY000) persists after full reinstall

So I've been working on a rails server with MySQL and suddenly can't access my database. When I try to log in with mysql -u root -p I get ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2). I've read most of the forums I can find and looked through all the logs trying to reset mysqld.sock. I've tried reinstalling and repackaging unsuccessfully. The weird thing is that var/run/mysqld/ doesn't even exist after reinstalling.
So I decided to just back up my databases and overhaul everything. I cleaned out both apache and mysql with apt-get remove --purge and reinstalled. All went fine, apache launched fine, and then tried to relaunch mysql with systemctl start mysql which gave a prompt to check the log which says:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Fri 2016-12-16 23:56:19 UTC; 17s ago
Process: 15690 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Control process exited, code=exited status=1
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: Failed to start MySQL Community Server.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Unit entered failed state.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Failed with result 'exit-code'.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: Stopped MySQL Community Server.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Start request repeated too quickly.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: Failed to start MySQL Community Server.
Update - I created the folder mysqld, which seems to allow sudo mysqld --initialize to run. Unfortunately this yielded the error
2016-12-17T00:16:36.298825Z 0 [ERROR] Can't change data directory owner to mysql
2016-12-17T00:16:36.299212Z 0 [ERROR] Aborting
So no party yet. Any thoughts would be hugely appreciated.
edit /etc/mysql/conf.d/mysql.cnf :
sudo nano /etc/mysql/conf.d/mysql.cnf
add this line :
socket=/var/run/mysqld/mysqld.sock
then restart mysql service :
sudo service mysql restart

mysql randomly stopped working

hi my mysql was working i did nothing on it then today when i went to login to multicraft it gave me error 500 which means theres an issue with mysql and i tried to do $service mysql restart it didnt work so i did $service mysql status and i got this error
● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql)
Active: failed (Result: exit-code) since Wed 2016-01-27 16:39:39 CET; 24min >ago
Process: 27320 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
Process: 28147 ExecStart=/etc/init.d/mysql start (code=exited, >status=1/FAILURE)
Jan 27 16:39:39 ns3317389.ip-37-59-14.eu systemd[1]: Starting LSB: Start and >sto...
Jan 27 16:39:39 ns3317389.ip-37-59-14.eu mysql[28147]: /etc/init.d/mysql: >ERROR:...
Jan 27 16:39:39 ns3317389.ip-37-59-14.eu systemd[1]: mysql.service: control >proc...
Jan 27 16:39:39 ns3317389.ip-37-59-14.eu systemd[1]: Failed to start LSB: Start >...
Jan 27 16:39:39 ns3317389.ip-37-59-14.eu systemd[1]: Unit mysql.service entered >...
Hint: Some lines were ellipsized, use -l to show in full.
look in your /var/log/mysql/*.log logs
try to start mysql on the commandline
Example:
as root user: mysqld --console