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
Related
I can't login my MySQL server. I got many solutions via the internet but not working any single solution.
The first thing is to ensure that MySQL server is up and running. This procedure is different for different distros, but you can try
$ sudo /etc/init.d/mysql start
to start
MySQL is not starting.
As suggested, your first step is to bang out the typical commands: service mysql status and journalctl -xe to see what errors are reported. The usual suspects are permissions on the mysql data folder typically located in/var/lib/mysql (permissions should be mysql:mysql) and also errors in my.cnf (/etc/mysql/my.cnf or /etc/mysql/mariadb.conf.d/50-server.cnf for recent mariadb installs)
If your MySQL was previously running and now wont start, you might be dealing with table corruption. Get mysqlcheck running on it if this is the case. If you are going to attempt a database startup with innodb_force_recovery flag, make sure you have your data backed up prior to launching the database.
Let us know the output of these commands so we can further assist.
i have been spending hours figuring out problems in connection mysql to use mariadb eventually. here's a situation.
situation:
1.i use macbook, and i am not that familiar with computer programming.
i tried to connect java eclipse and mariadb. so i looked it up online.
and at the same time, i opened up terminal and started my mysql using
mysql.server start
and it worked. and i was supposed to download mariaddb.2.2 jar something to connect it with eclipse, but i mistakenly downloaded "mariadb-10.2.12-osx10.13-x86_64.pkg" and installed it. and i also typed
mysql.server stop
and all that kind of things. lots and lots of things so that i can`t even remember
after i found out i downloaded the wrong things, i felt like this is way beyond my skills, so i jumped back to play with mariadb.
i opened up terminal and typed
mysql.server start
and termial keeps showing me this until now
.180322 00:04:47 mysqld_safe Logging to '/usr/local/var/mysql/sinjinhos-MacBook-Air-146.local.err'.
180322 00:04:47 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
. ERROR!
i still think that this tragedy started beacause i installed mariadb again...
i literally tried everything and still couldn`t figure it out.
please help me!!
From your initial post you can see that mariadb is logging the following file.
180322 00:04:47 mysqld_safe Logging to '/usr/local/var/mysql/sinjinhos-MacBook-Air-146.local.err'
Inside that file you found the following error.
2018-03-22 0:36:36 140736284734272 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 48: Address already in use 2018-03-22 0:36:36 140736284734272 [ERROR] Do you already have another mysqld server running on port: 3306 ? 2018-03-22 0:36:36 140736284734272 [ERROR] Aborting
The key part of the error is Address already in use. Everything running on your computer that listens for connections (like a database or a web server) will listen on a specific port. MySQL (and therefore MariaDB) listens on port 3306 by default. The important part is that you can't have multiple applications listening on the same port!
So where do you go from here? I suspect you still have MySQL running on your laptop, and once you stop it you will be able to start up a new instance.
To check if MySQL is running you can use the following command:
ps -ef | grep mysql
If anything shows here then it is running, and you should stop the service. How you do this will vary depending on how you installed it - try mysql.server stop first and run the above command again. If it is still running and you can't figure it out then you can kill the service. This is not recommended and cause MySQL data corruption - although if you have no data there then you should be OK.
Example output of ps -ef. Yours should show MySQL near the end, and the second column shows the process ID which you can use to kill the process.
PID
\/
0 9504 9491 0 3:44pm ttys007 0:00.00 ps -ef`
So I would use:
kill 9504
You should then be able to start the service again.
mysql.server start
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.
environment
OS X El Capitan 10.11 , Mysql 5.6.26
What I did
mysql port was 3307 when I installed it. ( I didn't install it using brew.)
I changed the port 3306 to 3306 by editing /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist after using mysql with 3307 port for 6 months well.
I revised <string>--port=3307</string> to 3306.
I tried to stop and It didn't work. So I used following:
sudo kill -9 [PID]
It's killed and didn't start. So I changed the port 3006 to 3007.
I tried to start mysql server with following command and got a error.
sudo /usr/local/mysql/support-files/mysql.server start
ERROR! The server quit without updating PID file (/var/lib/mysql/nhnui-MacBook-Pro.local.pid).
And I found some helpful advices in follwing link.
reference link :
After MySQL install via Brew, I get the error - The server quit without updating PID file
I tried to change ownership of files, checking my.cnf file, checking error log file and all didn't work for me.
Finally, I removed /usr/local/mysql/datamysqld.local.err , /usr/local/mysql/datamysqld.local.pid and rebooted mac.and I can start mysql server.
The Problem
Then, the problem is above tip is not perfect for me.
mysql server was running after restarting mac. I checked it with 'ps-ef | grep mysql'.
Stop and start was success and then it didn't stop it again cause of same error!
Screenshot of the error :
Of course, I did it again (I mean deleting .err , .pid file / rebooting mac / cheking mysql ps / stop - start (well) / stop (got error)) and checked that it has same error.
Here is the error log : /usr/local/mysql/data/mysqld.local.err
Now, mysql server can't stop.
What can I do to solve this?
P.S - If it will be better to reinstall mysql, I should do that.
Make a backup of your system.
Dump your data into text files.
Uninstall everything releated to mySql (a quick Google search will point you to several how-tos)
Reinstall mySql from the package in the .dmg available from mySql website.
You can choose the latest 5.6.x or 5.7.x
Set the mySql root password and you're done.
When things get messy and all you can do is guessing what's the fix it's faster to reinstall given that a package installer is provided for mySql (you don't have to compile it yourself or play with brew/macports).
I have just upgraded to Kubuntu 15.04 and MySQL is no longer working properly. The error is:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
I have checked and there is no mysqld.sock file at that location (and no directory 'var/run/mysqld'). I've tried creating a directory at 'var/run/mysqld' and using chmod to make it writable by all, then restarting MySQL using 'sudo service mysql restart', but this doesn't solve the problem.
MySQL seems to be running (it's coming up as loaded & active when I run 'sudo service mysql status'). There's nothing in the MySQL error log.
I can't find any mysqld.sock file at all (did a search across the whole file system).
Any solutions before I give up and purge/reinstall mysql would be gratefully appreciated!
EDIT to add:
The MySQL process itself isn't in the process list. No errors are thrown when I start/restart MySQL using 'sudo service mysql', and /var/log/mysql/error.log is empty.
I managed to get it working by changing the permissions on /var/lib/mysql and then running "mysqld" at the command line
So presumably some sort of permissions screw-up that happened as part of the Kubuntu upgrade.