mysql.sock and rails - mysql

This is not necessarily a programming question, but this issue is definitely blocking development (not to mention that there are thousands of questions on stackoverflow related to this, but none that I can see that address the issue I'm dealing with).
I've been working with rails and mysql for several months. At the time I did the install, all was fine, and up until about a week ago, I was able to run migrations, phpmyadmin, etc. without any problems.
Today, I was trying to create a new application (following the railscast 323). I also use Rubymine for an IDE.
I created the project using the IDE, project.new and created a new Rails application. I then proceeded created the scaffolding along with a migration file. I then did rake db:create and it seems as if the DB was created. When I tried doing rake db:migrate, I got the following error:
'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
I checked my config/database.yml (the file was created by the IDE) and it does have
socket: /tmp/mysql.sock
Additional information:
There is a /usr/local/var/mysql/store_development directory, so it seems as if the database was created.
I can go to /localhost/phpmyadmin, but my root password is not accepted (I did not change the root password)
I have not re-installed mysql
I have not updated mysql
/tmp/mysql.sock no longer exists
/usr/var/mysql/mysql.sock does not exist
Any ideas?

First of all, make sure mysqld is running.
If yes, try this:
ln -sf $(locate mysql.sock) /tmp

Related

Linking MAMP on Mac to a different instance of MySQL and phpMyAdmin

I am using macOS Sierra 10.12.2, MAMP 3.0.7.3.
I have been using MAMP with the MySQL it comes with for a while but I need to run something (Magento 2) that requires a higher version of MySQL than the version MAMP comes with, and I don't want to upgrade that instance of MySQL that comes with MAMP. So I am trying to install a different instance of MySQL for use on this project. I still want to use MAMP's Apache server with PHP to run the project though. I also still want to be able to switch back to the other instance of MySQL.
I am essentially trying to follow this tutorial, but I also want to install phpMyAdmin: http://www.human-element.com/installing-magento2-on-mac-for-local-development/
I have installed MySQL 5.6.35 to /usr/local/mysql/bin
The MAMP MySQL is at /Applications/MAMP/Library/bin/mysql
/Applications/MAMP/Library/bin/mysql --version is 5.5.38
mysql --version is 5.6.35
It seems to be installed correctly but I want to use phpMyAdmin for it, which is where I am having trouble. I downloaded phpMyAdmin 4.6.6 and installed it to /Applications/MAMP/htdocs/phpMyAdmin-4.6.6 (as I still need MAMP to run it). But it seems to be linking with the MAMP instance of MySQL and not the new instance of MySQL. I can only log in with credentials for the MAMP MySQL users and I see all my MAMP databases.
If I go to localhost/phpMyAdmin-4.6.6/setup I think the setup must be wrong but I'm not sure how to specify the other MySQL instance:
I tried changing the server socket path to /tmp/mysql.sock too - this had no noticeable effect.
I also have some symbolic links set up, although I admit I don't really understand what this is for...
cd /var/mysql/
# This one was set up before when I was just using MAMP:
mysql.sock -> /Applications/MAMP/tmp/mysql/mysql.sock
# This is the equivalent I set up (removing above one) for the new instance, but not sure if correct:
mysql.sock -> /tmp/mysql.sock
I've tried switching between both but it doesn't seem to have any effect on phpMyAdmin.
Can someone explain how I link the new version of phpMyAdmin with the new instance of MySQL?
Since you're essentially trying to run two MySQL instances at the same time, you have to make sure they're not using the same socket and TCP/IP port. These things are configured in the MySQL configuration file. I suggest not messing with the MAMP installed version, so edit the one you installed and make sure the port and socket path are different. Also make sure your data directory is different; you can't use the same datadir for two MySQL instances at the same time, and certainly not changing between versions, either. Once you have that sorted out, you can configure phpMyAdmin to connect to them both (you can define more than one server, based on port, hostname, and/or socket).

Problems with mysql config - want to understand

i know that there are many questions which are connected with my question, but nothing helps me to come to my goal.
I'm on mac osx 10.10.4
in the past i had MAMMP installed on my mac. Later i deleted it to configure my local hosts by my own. In the meantime i use vagrant for this. But i want to understand how the local mysql config works.
My problem:
If i type "mysql -uroot" i get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
The /Applications/MAMMP/.. folder are deleted and not there. So i think there must be a config file where this is inserted. But i cant find this file. Not in /etc/my.cnf and not in /usr/local/mysql/support-files/... nowhere...
Could anyone give me hints where my config for that is destroyed and how i can reapair it?
Would be great to hear from you guys. Thanks

2 MySQL installations (now one lost)

Ok I have a mess of a problem. MySQL was installed on my machine (mac) already but I could not login via terminal (fairly new machine, to me). I had already been working with a couple databases via a SequelPro and decided to login via terminal for a couple jobs.
I couldn't and couldn't figure out why not. I ran brew install mysql and to my surprise it installed mysql. When logging in via terminal I was taken to this instance of MySQL that did not have my databases. Now, I restart SequelPro and it now logs into the new instance vs the one that has my data.
Any idea where I can find my databases and get them to use this new instance? Or any thoughts on how to clean things up in general?
---update---
The DB is InnoDB
/usr/local/bin/mysql
/usr/local/Cellar/mysql
/usr/local/Cellar/mysql/5.6.25/bin/mysql
/usr/local/Cellar/mysql/5.6.25/include/mysql
/usr/local/Cellar/mysql/5.6.25/include/mysql/mysql
/usr/local/Cellar/mysql/5.6.25/share/doc/mysql
/usr/local/Cellar/mysql/5.6.25/share/mysql
/usr/local/include/mysql
/usr/local/Library/LinkedKegs/mysql
/usr/local/opt/mysql
/usr/local/share/doc/mysql
/usr/local/share/mysql
/usr/local/var/mysql
/usr/local/var/mysql/mysql
/usr/local/var/mysql is where my databases from the first instance are. /Cellar is where homebrew installed MySQL. I got a recommendation in the comments to add a symlink...not sure which folder I should use as source or target in this case.
Also, not sure how I would start the database from the old location either.
Any help is most appreciated!
Short script to get the old db running:
GO to the working database data location
Go up one directory
Shutdown any mysqld.
mv database_directory database_directory.backup
Symlink the data directory of any other mysql:
ln -s old_data_directory database_directory

Error 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

Please don't post this question as duplicate. I am trying to configure mysql for about 3 weeks now. Someone should really help me.
I recently installed MySQL 5.1 in a Lenovo laptop to do my project. The laptop is running on Windows 8.
The installation was fine but when I tried to configure MySQL it worked till the last page.
There am getting Error Nr 2003.
I tried it through the command prompt, through services in the control panel. But the problem is that the mysql service is not starting at all. Why it is not starting ? What will be blocking it from starting ?
First you need to start mysql service it is the problem for this above
error.
In case you cant start mysql service means you need to install mysql service.
Steps for install mysql service
Step 1: open command prompt and go to the mysql installed location (for example c:\Program Fiels\MYSQL\Mysql Server5.0\bin\)
Step 2: mysql --install
Step 3: start mysql service using the command NET START MYSQL command
then connect mysql using username and password.
Assuming the service is already running and you still get this error connecting to the localhost using the mysql client, then make sure you have an entry for "localhost" in your hosts file. This was the case I experienced.
I resolved this situation following the following process. After adding the MySQL path to the environment, I kept invoking the program and then checking Event Viewer in the Application Log for MySQL errors that referenced old commands in the ini file. After removing them, what was hanging me up was that the installer was looking for errmsg.sys in a folder that didn't exist, \bin\share. Those folders DO exist, but on the same level, not nested. So I added the folder share to bin and copied errmsg.sys from share to the new nested share, and it worked.
Now that its running, I intend to redo a proper configuration using the workbench, just to gets my ducks in a row.
hth
Go to Run type services.msc. Check whether MySQL services is running or not. If not, start it manually. Once it started, type mysqlshow to test the service.

Should I reinstall Mysql?

I'm getting kind of desperate here trying to get mysql to work on osx lion.
I've been through nearly every article on the web these past few days looking for a way to fix the problem with the error.
When I try to start the server is gives this error:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
when I try to create a database with 'rake db:create' it gives the same error.
sometimes it says that or I get errors about "please install gem-blabhalbhabhlb". And that gem doesn't exist.
I was able to install mysql in terminal using the dmg version from mysql's site but after I deleted the installation files it just stopped working- as in when I run
rake cd:create
I get the mysql.sock error.
I'm going insane.. please help
For me I often need to force mysql to not use unix sockets, but regular php sockets.
To do this, connect to 127.0.0.1 instead of localhost. Works 90% of the time, all the time.
Major credit to John P. for helping me get this working last night
The first thing was to uninstall mysql using 'brew uninstall mysql'.
Then to install mysql from their development site. The community .dmg 64 bits version.
Then to find out where the path was pointing.
So in updating the paths he had to find where bin/mysql was and make sure bash_profile had it's path there.
PATH=$PATH:/usr/local/mysql/bin
The essential step after that was to 'source' the file so he had me run this command.
source ~/.bash_profile
From there mysql works flawlessly.