mysqld.sock missing after server restart; MySQL server fails to start - mysql

I manage a local intranet website which runs on Ubuntu. Now, each time I restart the server, the mysqld.sock and mysql.sock files seem to disappear. This causes the MySQL server to not start.
Is this a common problem? Each time, I have to re-install the MySQL server and client to have it appear again.

The mysql.sock file is created when MariaDB starts and is removed when MariaDB is shutdown. It won't exist if MariaDB is not running.
Multiple my.cnf files can conflict. Check to see if you have multiple my.cnf files on your system. Possible locations include:
/etc/mysql/my.cnf (MariaDB default)
/etc/my.cnf
~/.my.cnf
Try to re-initialize your data directory 'offline' using mysql_install_db.

For me the case was that an OS update turned /var/run/ into temporary directory that was cleared on every restart.
Solution was to enforce recreating of /var/run/mysqld on every startup using one of the two methods described here: https://askubuntu.com/a/306479/567859

Related

Changes to my.ini Not Persisting when using MySQL

I'm attempting to update some variables for my MySQL database server; I am running Maria version 10.3.12 on a Windows 10 64-bit laptop. I have attempted to update the my.ini file located here:
C:\Program Files\MariaDB 10.3\data\my.ini
I am adding the following lines to a rather simple my.ini
max_allowed_packet=64M
interactive_timeout=86400
wait_timeout=86400
I have saved the changes to the my.ini; but when I restart the database server using mysqld restart at the command console, and then log back into the client, I expect to see my changes using SHOW VARIABLES LIKE 'max%' and what I end up seeing is the default value. The default value for max_allowed_packet is about 16M and for the other two it is 28800.
There are numerous articles that relate to this; having poured over them I am aware of how to use the SET command to update these from within the client. My goal though is to make a permanent change.
I have no doubt I have overlooked something; any feedback is appreciated.
You can identify path of the configuration file by looking into services:
Open services and find MariaDB Service instance
Right click and click on Properties
You should see something like "C:\path\to\exe" --defaults-file="c:\path-to-ini\my.ini"
then you can edit correct configuration file
I found the solution. After making the changes noted in my post I was attempting to restart MySQL daemon using the Windows Command line and the following command:
C:\Users\david>mysqld restart
2019-03-14 21:05:48 0 [Note] mysqld (mysqld 10.3.12-MariaDB) starting as process 8548 ...
The results can be seen below the command which is mysqld restart
MySQL being installed and run as a Service, clearly this was not the was to restart it; so I restarted it using the Services.msc:
Typing Services.msc into the search bar
Selecting Services
In the Services app find MySQL
Right clicking MySQL and selecting
Restart
This caused the my.ini file to be reread.

MySQL Server on MAMP-Windows Will Not Start

I am using MAMP 4.1 on Windows 10 and cannot get MySQL server to start. When I uninstalled MAMP and re-installed it MySQL server starts up, but when I stop it, it will not start back up. I also went into the \mamp\db\mysql\ and deleted the four log files hilited below. Then I turned the server off, then back on, but only Apache starts up, not MySQL.
There is also a process running in services called MySQL80. When I try to start it I get the error message shown. I have tried many ways to delete it, including going to the command prompt and using "sc mysql80" and going to 'regedit'. MySQL80 does not show up anywhere so that I can delete it.
Also, the Resource Monitor below shows that Apache is running on port 80, but nothing on port 3306. And yes, my MAMP Preferences are set to port 3306 for MySQL.
When MySQL was running, I had 2 processes of 'mysqld' listening: one session on IPv6 Port 3306, and the other session on IPv4 Port 3306?
What's wrong and how do I fix it?
And, is there suppose to be (2) sessions of 'mysqld' both listening on port 3306 where one is on IPv6 and the other is on IPv4?
Thanks Community.
MAMP Control Panel
mysql80 Service
Resource Window with Ports Listed
MAMP Log Files
I had the same problem. I contacted mamp support, and their answer was the following; it worked for me. Hope this helps you too. Stop all servers in MAMP.
The below assumes your MAMP installation directory is C:\MAMP\.
For MAMP:
With Windows Explorer go to folder C:\MAMP\db\mysql\
First backup all files that begin with mysql-bin.*, then delete them (including mysql-bin.index file.)
Then try starting all MAMP servers again (wait for MySQL to turn light on).
After that stop all MAMP servers again.
You'll now try to disable binary log-bin in MAMP (or MAMP PRO)
Open up MySQL configuration file in text editor of your choice: C:\MAMP\conf\mysql\my.ini
Find following text: log-bin
Comment this line by adding # character at start of line.
#log-bin=mysql-bin
Save and restart servers
After that put the mysql-bin.* files back in their place.
Turn off your MAMP Server.
Locate your db folder for mysql. Example: C:\MAMP\db\mysql
Rename the mysql-bin.index file to mysql-bin_old.index (or anything really)
Turn on your MAMP Server
This is a very common issue with MAMP. If this happened to you out of the blue, this is probably the fix.
This is what I did to solve this issue:
Quit MAMP if open
Navigate to /MAMP/tmp/mysql
Rename mysql.sock.lock
Restart MAMP
my issue was Avast Antivirus blocking MAMP, disabled for 10 minutes and Apache started
I had the same problem today.
I did try removing everything from C:\MAMP\db\mysql\ and tried to restart MAMP & servers. But it failed.
Then I noticed the following error in the mysql log file /MAMP/logs/mysql_error_log.err
[error] Cannot open windows event_log ; check privileges
This basically means that you don't have sufficient access.
So
I replaced all the files that I originally deleted
shutdown the server & MAMP.
Now right click on the MAMP icon & choose run as administrator
Now it starts up normally
Uninstall entire MAMP and also any other xamap and wamp if you install previously.
Check the drive C. No any other folder or file related to this present there.
then reinstall MAMP again. All the problems are solve your apache and mysql both start.
please vote me.
This is what worked for me :
Click on Start Servers in MAMP
Manually click on mysql.exe in
MAMP installation folder (C:\MAMP\bin\mysql\bin\mysql.exe)
Tip : You can pin mysql.exe to Start Menu so you don't always have to search for this folder

MySQL Workbench Unable to Retrieve Disk Space in Data Dir, Server Stopped

I had mySQL workbench working fine a few weeks ago. Now, any time I log in, I get no connection. Upon inspecting Sever Status, it is showing Stopped. Also, under the Server Directories, it says Unable to Retrieve next to Disk Space in Data Dir.
I also noticed that the configuration file was wrong, or outdated? The Configuration File originally read:
C:\ProgramData\MySQL\MySQL Server 5.5\my.ini
But I looked and there was no MySQL Server 5.5 file in my directory. I do have a MySQL Server 8.0 folder, so I changed the Configuration File to:
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
However, this fails to solve the problem. I've also attempted to run Services from the Start Menu, right click on MYSQL80, and choose start - and it says the service has Started then stopped.
I'm not even sure this missing or mis-directed file is the issue, or whether it's the Unable to Retrieve Disk error (or both are causing the server to fail). I recently changed my login password for my computer - but I doubt that is related to the login credentials for MySQL, right? (I see MYSQL80 properties has password for 'log on' option, but I have no idea what this password even is, or how to change it).
I've also read about this problem online and cannot seem to find an answer that solves the issue. I've tried running MySQL Workbench as an admin too, and that doesn't work either.
Can anyone point me in the right direction? Is there a way to get the server up and running again without a bunch of complicated command line? I appear to have mysqld.exe in the bin file in MySQL 8.0
Thanks all in advance!
In MySql Workbench Server -> Startup/ShutDown -> Start Server.
This Worked for me.
When the my.ini file is messed up I think the best solution is a total uninstall/delete and manual install. Before you do any of the following make sure you go to your current data dir and save your database folders. Then dlete all of your current MySQL related directories and uninstall MySQL and MySQL workbench.
I had this problem when I installed MySQL 8.0.15 with the community installer. The my.ini file that came with the installer did not work correctly after it had been edited. I did a full manual install by downloading that zip folder. I was able to create my own my.ini file containing only the parameters that I was concerned about and it worked.
download zip file from MySQL website
unpack the folder into C:\program files\MySQL\MySQL8.0
within the MySQL8.0 folder that you unpacked the zip folder into, create a text file and save it as my.ini
include the parameters in that my.ini file that you are concerned about. so something like this(just ensure that there is already a folder created for the datadir or else initialization won't work):
[mysqld]
basedire=C:\program files\MySQL\MySQL8.0
datadir=D:\MySQL\Data
....continue with whatever parameters you want to include
initialize the data directory by running these two commands in the command prompt:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --default-file=C:\program files\MySQL\MySQL8.0\my.ini --initialize
install the MySQL server as a service by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --install --default-file=C:\program files\MySQL\MySQL8.0\my.ini
finally, start the server for the first time by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --console

MAMP 4.1.0 on Win 10 not starting MySQL

I've installed MAMP 4.1.0 on Win 10 Home on my HP laptop (AMD Ryzen 5 processor / 8G Ram / 1TB HDD) and am having issues keeping MySQL (V.5.7.24) running. It defaults to ports 80 for Apache and 3306 for MySQL. Apache starts and runs fine. MySQL only starts upon first initial installation and it works perfectly at that point. I can access via phpMyAdmin with no problems. But if I shut the servers down and attempt to restart, only Apache starts, MySQL does not. I've tried rebooting, but MySQL will NOT restart. I've checked the MySQL error log, but nothing appears to show anything associated with the problem. If I try to use phpMyAdmin while MySQL is shown as not up in MAMP I get the error messages shown in the attached file phpMyAdmin Errors. If anyone has any ideas on what the problem might be and what I can do to resolve this, please respond. I appreciate any help.
I had the same problem. Contacted mamp support. Their answer was the following. It worked for me. Hope this helps you too.
Stop all servers in MAMP.
For MAMP:
With Windows Explorer go to folder C:\MAMP\db\mysql\ (if C:\MAMP\ is your installation directory).
First backup all files that begin with mysql-bin.*
Then delete all files that begin with mysql-bin.* (including mysql-bin.index file.)
Then try starting all MAMP servers again (wait for MySQL to turn light on).
After that stop all MAMP servers again.
You'll now try to disable binary log-bin in MAMP (or MAMP PRO)
For MAMP:
Open up MySQL configuration file in text editor of your choice:
C:\MAMP\conf\mysql\my.ini
This example assumes C:\MAMP\ is your installation directory.
Find following text:
log-bin
Comment this line by adding # character at start of line.
#log-bin=mysql-bin
Save and restart servers
After that put the mysql-bin.* files back in their place.
Try the following. It fixed my issue.
Stop your MAMP Server.
Find the db folder for mysql. In my case: C:\MAMP\db\mysql
Rename the mysql-bin.index file to mysql-bin_old.index
Start your MAMP Server

Change database files location in MySQL administrator?

I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)
--Under the startup variable --> General Parameters --> I changed Data directory: from C:/Program Files/MySQL/MySQL Server 5.0/data to D:/....., but after I stopped the service and restarted it, the following error appeared:
Could not re-connect to the MySQL Server.
Server could not be started.
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
Has anyone else had this problem?
Normally it works like this:
shut down MySQL
change the [mysqld] and [mysqld_safe] datadir variable in the MySQL configuration
change the basedir variable in the same section.
move the location over
restart MySQL
If that doesn't work I have no idea. On linux you can try to move the socket to a new location too, but that shouldn't affect windows. Alternatively you can use a symbolic link on *nix what most people do I guess.
In Windows
Navigate to C:\Program Files\MySQL\MySQL Server 5.4\ and locate the my.ini file
Find the SERVER SECTION and go to approx line 76 and modify the datadir line to where you want your MySQL application data to be stored
Now navigate to C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.4\data\ and copy and paste the mysql folder into your new location.
Restart the MySQL Server in Control Panel > Administrative Tools > Service
You also have to manually modify mysql's configuration (usually my.conf)
MySQL Administrator cannot be used for tasks like this. It is merely a tool for looking at MySQL servers, despite its name. Relocating data is described in many MySQL tutorials and in the manual IIRC. But basically it's just moving the data to a new location while the server is shut down and then correcting the paths in the servers config file.
After that you should be able to restart the server and connect MySQL Administrator to it.
Make sure you give the Network Service Full permissions in the security tab of Windows Explorer options. If the server can't read/write etc. to the selected folder the service will either not start or it will attempt a start and shut right down.