I try running command ~$ mysql -u root -p
But the following error comes along-ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)
I have already installed mysql-client and mysql-server.Even it is not working
Start deamon sudo systemctl start mysql or run mysql -u root -p as root
My WordPress site ( http://steamboatperinatalconference.com ) just recently started going down and spitting this error
" Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/www/html/wp-includes/wp-db.php on line 1568 "
I have checked the db password and its ok, also reset the instance and sql server and both are running, I'm able to connect to my database through mysqlworkbench.
Not sure why my website won't display if the database is up and running.
Any help is appreciated.
First kill the processes with:
sudo pkill mysql
and
sudo pkill mysqld
restart mysql
sudo service mysql restart
now you should be able to log in
mysql -u root -p
It turns out in order to fix the issue I was having I needed to run a sudo yum update on the AWS ec2 instance, after performing the update the page was back up and running
my.cnf (location of file /etc/mysql/ folder) configured with
socket=/var/lib/mysql/mysql.sock
check for MySQL is running with the following command:
mysqladmin -u root -p status
changing permission to MySQL folder. If you are working locally, you can try:
sudo chmod -R 755 /var/lib/mysql/
I'm new to Ubuntu.
I have xampp installed on Ubuntu and works just fine. But when I am trying to run mysql -u username -p pass from terminal I recieve this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'.
I've tried to install mysql-server again but it runs completely separate (has another database....and is not working with phpmyadmin from xampp).
How can I make it work in terminal from xampp server?
Your mysql-database might not be running at all!
Try this: sudo /etc/init.d/mysql start then mysql -u yourusername -p yourpasswrd
I've gotten a new laptop and after installing the newest version of xampp I cant log in to mysql as -u root.
I made sure that mysql is turned on in xampp.
Lines I've tried
cd\xampp\mysql\bin>mysql.exe -u root -p
cd\xampp\mysql\bin -u root -p
I've also tried starting mysql.exe directly and couldnt log in with similair commands.
The default setup of Xampp does not set a root password in mysql.
Try connecting without the -p. c:\xampp\mysql\bin\mysql.exe --user=root
The following is from the FAQ - https://www.apachefriends.org/faq_windows.html
Is XAMPP production ready?
Here a list of missing security in XAMPP:
The MySQL administrator (root) has no password.
I just installed MySQL 5.5.27 on WinXP. When I open a command prompt (Start -> Run, and type "cmd"), I can access MySQL by running "mysql -u root -p". However, when I open a Cygwin terminal and try the same thing, I get this error
$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2)
Indeed, there is no "/var/run/mysql.sock" file.
If you specify the host on the command line, this issue should go away:
mysql -u root -p -h 127.0.0.1
You can also create a my.ini that mysql will use:
echo [client] >c:\my.ini
echo user=root >>c:\my.ini
echo host=127.0.0.1 >>c:\my.ini
Then you can just type:
mysql -p
You can even add the password:
echo password="abracadabra" >>c:\my.ini
Then, just type:
mysql
and you're in!
See also https://serverfault.com/questions/337818/how-to-force-mysql-to-connect-by-tcp-instead-of-a-unix-socket
Try adding this to your command:
-h 127.0.0.1
The problem is that the mysql client default host is localhost, and it treats localhost specially, using a unix socket, which is accessed via that file, but your server may not be configured to listen on the unix socket.
However, if you access the same server via the loopback IP 127.0.0.1 it will use a TCP socket instead of the unix socket and (assuming the server is online) it should work.
Just to save few keystorkes,
Add following alias to your ~/.bashrc file.
alias mysql='mysql -u root -h 127.0.0.1'
After adding this, You can just type "mysql" in your terminal & there you go right inside mysql.
As most of people mentioned here - one of the solutions will be to use aliases. Don't like them to be honest because they are preventing me learning some really nice Linux commands :) It's just a joke. But the best way for you, as I think, will be to locate a ~/.bashrc file located in your home directory and put there:
alias mysql="mysql -h 127.0.0.1"
Don't forget that you have to restart your session in order for this solution to work or you may type bash command at the same terminal session - it will reload all your bash settings. Good luck!
P.S. I suggest you to close all other terminal windows before editing .bashrc because you may just got a read-only file. I had such issue under Win7x64
I successfully installed MySQL in Cygwin on my PC according to Rafael Hart. I created a database and performed some queries and everything worked great.
The next day when I tried logging into MySQL, I got the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql.sock' (111 "Connection refused")
Apparently, when you shutdown your PC, the services also get shutdown and do not restart on boot.
To fix the problem, I typed the following command to restart the mysqld service:
$ mysqld_safe &
Then everything started working.
Here's how to run MYSQL from cygwin
Go here:
https://cygwin.rafaelhart.com/setting-up-mysql-on-cygwin/
To begin MySQL setup run the following:
mysql_install_db
Run mysql - you'll get a firewall alert from windows if you have it active.
mysqld_safe & Immediately following that, it would be wise to run the following:
mysql_secure_installation