Reinstalling MySQL on Ubuntu - mysql

MySQL is broken on my Ubuntu OS. It throws the following error:
mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I wasn't able to repair it. So I want to reinstall MySQL. But I didn't find an effective way.
I used sudo apt-get remove mysql-server-5.1,
But after the re-installation, it is still throwing the same error. Any help?

Restart mysqld.

I don't know how I change the passwrod,this may occur when i use some rails app,
in fact i have set a password for mysql,but when i execute rails rake:db:schema:crate, seems it set the password empty

Related

Mysql Not Working After El Capitan Upgrade

I recently upgraded my Mac Pro to a Mac Mini and used the migration assistant to transfer all my files and applications across to the Mac Mini.
I also re-installed macports and configured apache etc. So I've managed to get my localhost and php working on the new machine.
However I am now unable to start mysql from terminal?
When I try my usual:
mysql5 -u root -p;
and got the following error:
Error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
I've also tried restarting mysql:
sudo opt/local/share/mysql5/mysql/mysql.server restart
and got the following error:
ERROR! Manager of pid-file quit without updating file.
When I navigate to my mysql5 directory /opt/local/var/db/mysql5/ I see a list of my databases, and see the following PID files:
myName.local.pid
and
localhost pid
So the structure is similar to what was on my old Mac but I confused as to what is causing mysql to not start?
Interestingly, mysql must be still working because when I run an .php scripts in my browser the mysql queries work and the data is being retrieved.
Any help much appreciated.
SOLVED
I would like to share the solution that I came across to resolve this issue.
When you update to El Capitan from a previous version of OSX your mysql settings get lost. When you try to connect via:
mysql5 -u root -p;
I was getting the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
The problem was with my.cnf!
The default configuration of macports mysql does not come with a my.cnf (it does however have others my-medium.cnf, my-small.cnf) so the Macports mysql client is going to look where the Macports server is set to look.
I also learned that if you've changed the socket path away from the default then you need to tell everything where it is. Most programs have a hard coded default that can be overridden, I had overridden the macports default to the one php is compiled to, so you need to tell the client what you've changed it to otherwise how is it supposed to know.
Because I did not have a copy of my.cnf in opt/local/share/mysql5/mysql, the client did not know where to look for the socket. So I had to define the path to the socket in the my.cnf for both the [client] and [mysqld] configurations.
The in my case the path to the socket should have been:
socket = /opt/local/var/run/mysql5/mysqld.sock
I then restarted mysql:
sudo /opt/local/share/mysql5/mysql/mysql.server restart
And SUCCESS at last.
Hope this helps.

Issue when starting MySQL on Mac OSX

I downloaded Mac OSX MySQL Community edition (http://dev.mysql.com/downloads/mysql/), and when I start it at
/usr/local/mysql/bin/mysql
I meet with the following issue:
ERROR 2002 (HY000):
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Anyone have any good ideas? Thanks in advance.
Meeting with new issues cannot connect to local MySQL instance using MySQL WorkBench, here are my setup and error, looks access denied and anyone have any ideas?
Most likely the service isn't running or it's looking for the socket in the wrong path.
The /usr/local/mysql/bin/mysql call you made is actually the client, not the server/service.
There should be a mysql_safe executable in that same directory -- try calling that first (you may have to be root).
sudo /usr/local/mysql/bin/mysqld_safe

Connection error on MySQL Workbench 6.1

I just upgraded my comp to the beta Yosemite and now my MySQL is giving me a connection problem.
I used to be able to run this command in terminal and get results:
/usr/local/mysql/bin/mysql -uroot -e "SELECT * FROM table_name"
But now it returns this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I'm not sure how I even set this connection up in the first place so please any answers, pretend I'm not too savvy with this... Thanks in advance!!
First, verify that your MySQL server is running:
mysql.server start
If that was not the issue, try starting the MySQL server in safe-mode using these instructions
Okay I found out what happened. When I upgraded to Yosemite, this file disappeared or something. Anyway I had to reinstall the files. Everything is here in this link under the MySQL section:
http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/

MySQL not working on Ubuntu 11.04

I run the mysql command at the command line but I get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I've Googled a lot but I'm unable to resolve the issue.
Please HELP!
It sounds like mysql isn't running. This will tell you if it is or not:
sudo netstat -tap | grep mysql
That's because the path you specified doesnt have the socket required to connnect to the mysql. This problem has happened with me. Either you can reinstall mysql or search for the mysqld.sock and then move it to the specified directory.
Try running this command to start the mysql server
/etc/init.d/mysql start
/etc/init.d/mysql restart

mysql connection error on rails 2.3.14

I've been trying to work MySQL on Rails 2.3.14. I've to work with Rails2 but i can't work MySQL.
I've setup MySQL with brew according to http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/ this tutorial but when i tried to run
$ mysql
i've faced to
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Why?
Thank you.
All right mates.
I got it.
First I killed all mysql process
killall mysqld
and then I uninstalled mysql from brew
$brew uninstall mysql
$brew cleanup
after that I installed mysql again as http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/
so I fixed the problem.