Okay, I've looked around, but I'm very confused with the problem. Please forgive me if it's something stupid. :*S I'm running 32bit Debian 6.0.6.
root#debian:~# service mysql start
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
So, the the service fails to start.
root#debian:~# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
And this is the error given when running the command mysql. Is this error because mysqld failed to start? Or is there another reason?
I went to the directory, /var/mysqld/ and there wasn't a file named mysqld.sock. Is that the issue, or am I an idiot? hahah. Any help would be greatly appreciated. Thank you for your time.
EDIT: Also, it appears that logs associated with mysql, such as mysql.log and mysql.err have no value to them, they're blank. Also, I've chmod 777'd all the directories that mysql acts in. The service still continues to refuse running.
Try to track down the error a bit differently. Run MySQL in the foreground.
mysqld_safe --log-error=/var/log/mysql.err
This should produce a log with some details at /var/log/mysql.err hopefully and add the details to your question if any in case my solution below doesn't work and someone else can help.
You may end up getting an error mysqld_safe: command not found and if you do, use the locate command to find it.
locate mysqld_safe
This will tell you where it is. For example, if it returns /usr/bin/mysqld_safe, run the command
/usr/bin/mysqld_safe --log-error=/var/log/mysql.err
If I had to hazard a guess, you will find an error about pthreads.
InnoDB: Error: pthread_create returned 12
If this is the case, the easy solution is to disable InnoDB for MySQL. Chances are you won't need this, so disable it in the config.
To turn off InnoDB, edit the MySQL configuration file at /etc/mysql/my.cnf and add this to it
skip-innodb
Now start MySQL
/etc/init.d/mysql start
I had the same problem.
The /tmp dir was not writbale, so MYSQL couldn't write some needed file.
Just do this :
chmod 777 /tmp
and restart mysql
/etc/init.d/mysql start
I had the same problem for days, and it was my network (DHCP) along with mysql configuration (which I always experiment with).
This may help you:
open /etc/mysql/my.cnf
find bind-address and make sure the ip address is correct or commented out like so
#bind-address
I had the same
I've uninstalled zlib1g-dev and all went fine
Related
My Mysql server on MAMP won't start.
This is the error:
161224 00:15:00 mysqld_safe Logging to '/Applications/MAMP/logs/mysql_error_log.err'.
161224 00:15:00 mysqld_safe Starting mysqld daemon with databases from /Applications/MAMP/db/mysql56
161224 00:15:01 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended
I already tried the following commands:
> ps aux | grep mysql
> lsof -i
> sudo killall -9 mysqld
But the server is still not working.
Help ?
Remove the files ib_logfileN (N being the number) from the MAMP/db/mysql56 folder.
Then restart MAMP.
Should Work!!
Edit: If the above step doesn't work completely, please remove the ibdata<n> file as well, based on the comments.
I am working on oS-X (Mac), I was wondering around and came to see this post which help me a lot.
Many readers are being able to solve this problem thanks to the amazing here are the step to fix it out--
This issue generally occur due to explicitly closing of MAMP serves.
Quit MAMP.
In the finder go to Applications/MAMP/db/mysql/
Delete the last log file (look for a file named ib_logfileN – being N the log number Eg-ib_logfile0 and ib_logfile1) we can see in below image.
Please back up these before you delete them.
Restart MAMP.
It Worked for me, hope will work for you too..
I killed the process mysqlid via Activity Monitor on MacOS and restarted MAMP and MySql run successfully.
Update: Even this solution works without restarting MAMP.
My MAMPs MySQL stopped working after a power failure, this worked for me:
Stop servers from terminal
cd /Applications/MAMP/bin
./stop.sh
Create my.cnf file in /Applications/MAMP/conf with the following:
[mysqld]
innodb_force_recovery = 1
Start MySQL from same terminal window.
./startMysql.sh
Stop MySQL once it has recovered (Check the log in /Applications/MAMP/logs/mysql_error_log.err).
./stopMysql.sh
Remove the lines from my.cnf, save and start the servers as usual from the MAMP app.
MAMP is so touchy. Here's what worked for me:
cd /Applications/MAMP
Move or rename: mv tmp tmp_OLD.
Recreate the folder and a subfolder:
mkdir tmp; mkdir tmp/mysql
Now start mysql from MAMP. I think it's possible the socket lock file (tmp/mysql/mysql.sock.lock) gets corrupted and needs to be regenerated.
In some cases it may possible that the MySQL is already running on 3306 port. So, you can change the port number with 3307.
P.S: If you are bound to use 3306 in that case I think you can stop existing MySql server and let MAMP to do it for you.
I tried everything but I don't know why I didn't find this solution yet.
Quit Mamp
Go To /Application/Mamp/tmp/mysql
Delete File mysql.sock.lock
Start Mamp Server and that's all
+1 if this answer is helpful :)
I have recently installed MySQL directly from the website (mysql-5.7.9-osx10.10-x86_64.dmg) and I have run into a great deal of difficulty that started with trying to change the given password. The error that was returned was:
[Warning] Using a password on the command line interface can be
insecure. mysqladmin: connect to server at 'localhost' failed error:
Can't connect to local MySQL server through socket '/tmp/mysql.sock
(2)' Check that mysqld is running and that the socket:
'/tmp/mysql.sock' exists!
From here I attempted to find the "usr" folder (hidden files are showing) or even anything that closely resembles MySQL anywhere on my computer and got nothing except for installation .dmg files.
I know that MySQL was installed because it is now able to be started and stopped in the System Preferences pane, but clearly none of my commands are working and I keep getting this error no matter what I do:
mysql: command not found
Can someone give me some clue as to what I am missing? I've become fairly desperate and can't figure out what I am doing wrong. I am running El Capitan.
Well, if you're saying that MySQL is running, you can try looking for it via terminal command like this:
ps aux | grep mysql
which should give something like
12345 ... 5 Apr16 9:09.32 /usr/local/Cellar/mysql/5.6.17/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.17 --datadir=/usr/local/var/mysql --bind-address=127.0.0.1
so basedir and datadir is probably the most valuable outputs here (please note that your path most likely will be different).
On top of it, in order to get mysql command running through terminal you have two options
Create simulink from mysql's basedir into your /usr/local/bin directory
ln -s /usr/local/Cellar/mysql/5.6.17/bin/mysql /usr/local/bin/mysql
Add mysql's basedir/bin to your path (need to add this to your ~/.bashrc to make it persistent)
export PATH=/usr/local/Cellar/mysql/5.6.17/bin/:$PATH
New terminal tab is required for these changes to catch up.
Cheers.
I'm installing Apache server, php, and MySQL on Windows10.
First two was successful but MySQL has a problem.
I installed MySQL into C:\mysql-5.7.10-winx64, and changed my.ini like this
basedir = C:/mysql-5.7.10-winx64
datadir = C:/mysql-5.7.10-winx64/data
port = 3306
I succeeded install but if I try to start, it shows like below
C:\Windows\system32>net start mysql
The MySQL service is starting.
The MySQL service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534.
However, if I check Computer Management>Event Viewer>Custom Views>Summary page events, it tells me "failed to set datadir to C:\mysql-5.7.10-winx64\data\"
If I make data folder manually, error message changed to
Can't open the mysql.plugin table
Please run mysql_upgrade to create it.." and some files are created in data folder
I tried to upgrade by typing mysql_upgrade but it failed.
mysql_upgrade: Got error: 2003: Can't connect to MySQL server on 'localhost' (10061) while connecting to the MySQL server. Upgrade process encountered error and will not continue.
How can I solve this issue?
Clear the "data" directory, then run command mysqld --initialize, and the command net start mysql, bingo!
1.For the error,
2003: Can't connect to MySQL server on 'localhost' (10061) while connecting to the MySQL server. Upgrade process encountered error and will not continue.
I ran the cmd as administrator and then go to \Program Files\MySQL\MySQL Server 5.7\bin\, and run
mysqld install
2.For the error,
C:\Program Files\MySQL\MySQL Server 5.7\bin>net start mysql
The MySQL service is starting.
The MySQL service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534.
Try
mysqld --initialize
and then
net start mysql
Thanks to Athan's answer. Those combination worked for me.
I also had the same problem and I wasted hours solving the issue, but in the end this worked.
Go to you C:\ProgramData\MySQL\MySQL Server 5.7 and copy the my.ini file from there.
Go to C:\Program Files\MySQL\MySQL Server 5.7 and paste it there.
Open cmd and run net start mysql
It would work like a charm.
Explanation:
MySQL couldn't find my.ini, therefore tried to create data in Program Files... where it had no rights to do so, therefore it says access denied every time you run it.
This is old but I was running into the same problem you were seeing. I thought I'd share this answer for anyone looking. I created the data directory as you did initially and tried to start the service and got "Can't open and lock privilege tables: Table mysql.user doesn't exist." I then deleted the contents of the data directory and instead initialized the data directory by running the following command from the bin folder.
mysqld --initialize [with random root password]
mysqld --initialize-insecure [without random root password]
I had the same error, after checked this document: https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization.html
I just clear data directory and add the --console option to initialize:
bin\mysqld --defaults-file=C:\my.ini
--initialize --console
Hope this help
MySQL Server can either be run as a Program or as a Service. You cannot run both. You should stop 'mysqld' Server Program before starting 'mysqld' Server as Service.
The 'mysqld' Server Program can be stopped either by typing
'CTRL + c' or by issuing
'mysqladmin -u root -p shutdown' command and issue the password when prompted.
You need download from https://dev.mysql.com/downloads/mysql/ previous GA versions, and after that copy directory "data" to your new mysql or outher directory what you write in configfile my.ini in directory mysql-"version" .
For your error, main cause is in your my.ini setting.
Since you are installing MySQL on Windows, you should define path like:
basedir = C:\\mysql-5.7.10-winx64
datadir = C:\\mysql-5.7.10-winx64\\data
These slashes must be doubled.
Then start your MySQL service again. I guess this time would work.
And here is official document from MySQL.
This saved my life,
Just turn off the windows firewall and Give he port number correctly as 3306 as default, then restart MYSQL server . After that turn on the windows defender firewall
Just work it fine.
Looks like my solution is not added yet,
I've installed mysql80 , edited my.ini in windows notepad and got the same error like topic author "... NET HELPMSG 3534." when I start mysql service,
and my issue was in extra bytes added by notepad at the begining (EB BB BF) on my.ini, when I edited (added the same changes) my.ini in other editor everything worked fine.
I have been using the LAMP stack on a Ubuntu setup.
It has been working fine, set up multiple databases everything is going fine, and then suddenly this morning I started getting database errors from the webpage I was using, then trying to access PHPMyAdmin got:
error #2002 Cannot log in to the MySQL server
I go into the bash prompt and try to log-in as the root user see whats up I get a similar error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
I checked that the mysql.sock file existed which it does, in the specified path in the error above. Permissions where all good, and owned by mysql. I reset the permissions just in case and still get the same error.
Here is the file as seen from BASH:
srwxrwxrwx 1 mysql mysql 0 Oct 21 05:10 mysqld.sock
I thought I would just restart the service, but get the same error when trying to stop, start or restart the service.
This really baffled me, I am no expert with linux or anything, but don't understand how this can suddenly happen when I didn't change any of the config settings, and it was running perfectly fine for the last few months.
I tried restarting Apache, and got the error:
apache2: bad user name ${APACHE_RUN_USER}
I don't think that is related to the MySQL stuff but thought it could be involved. The Apache error seems to more be with the set-up but knowing my luck being lazy has caused my to overlook simple things that has caused it all to come crashing down.
Any help on how to fix the problem, and more importantly prevent this occurrence the future would be greatly appreciated.
I have tried most things that were returned by a basic Google search, and a look around here. I have not yet tried deleting and recreating the sock file, but most other things so far have not worked.
EDIT:
I just wanted to add that the Apache server is still running fine, nothing wrong there even though I do get the error when trying to stop and restart it. Pages that don't rely on MySQL still load without issue.
I have also tried killing mysql processes through searching the PIDs and also as suggested below killall mysqld (and also killall mysql just for kicks). No processes found through these attempts.
I don't know if it is relevant or not, but I can't open (in vim) or view the mysqld.sock file (permission denied) even when using the superuser.
Have you tried using
killall mysqld
to kill the server instead of just ending the service, and then starting the MySQL service?
Or you could try deleting mysql.sock using
rm /var/run/mysqld/mysqld.sock
Then you would just need to run the MySQL server again by either starting the service or running
mysqld
It should create a new /var/run/mysqld/mysqld.sock for itself and all should go well.
Just a thought: this may have happened because the computer wasn't powered-off correctly, or perhaps MySQL just got a bit confused.
Create one micro instance swap space in Ubuntu
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
did you try to just restart the mysql server
/etc/init.d/mysqld restart
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
I am getting the following error
error: 'Can't connect to local MySQL
server through socket
'/var/lib/mysql/mysql.sock' (2)'
How can i restore the mysql.sock file?
[Edit]
I am trying to connect to mysql database from my ROR application. It was working fine till yesterday. But today I found out the mysql.sock file was missing. I don't know the reason of what led to deletion of mysql.sock file from location /var/lib/mysql/. How can i restore the mysql.file?
Thanks.....
Try this:
$ mysql_config |grep -- --socket
It should show you the socket path as compiled in to the server. If that fails, try running the mysql command and look for the socket path in the output of \s.
here is a rude yet quick way to solve this, but if your data or operation is important, you'd better find an other way
kill all the mysql process
now your mysql should be stopped, but locked.
So delete the lock file and restart mysqld
rm /var/lock/subsys/mysqld
/etc/init.d/mysqld start
I had the same problem and after spending some time i got the solution. From your terminal run this command -- sudo apt-get install mysql-server