Setting up MySQL server on OSX 10.7 (Lion) using Homebrew - mysql

I have successfully installed MySQL using Homebrew. However, whenever I type the command mysql I receive this error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I suspect this is a permission problem, as I have confirmed my system is looking for MySQL in the right location. However, I a novice with Unix(OSX) and don't know how to rectify the problem.
I am using OSX 10.7 (Lion)
which mysql produces /usr/local/bin/mysql

When you type 'mysql' you are running the MySQL client. The client needs to communicate with the server. If you simply run 'mysql' without any argument it assumes you are trying to connect to a mysql server that is located on 'localhost' using the user name as the user you are running the command as and without a password.
From the error it seems your server is not running yet. Start it by typing:
mysql.server start

Related

New MySQL Workbench Install (Will not connect to root) Ubuntu 18.04

My newly installed MySQL workbench is refusing to connect to the root of my newly installed MySQL Community Server. Whenever I attempt to access "Local Instance 3306" (the default MySQL connection) I get the following error message.
This error message does change if I open "Local Instance 3306" via the "edit connection" tab and then "test connection". I'll get a different but similar error code.
I can access the server via the command line
and can confirm that the server appears to be active also via command line.
It is a fresh install of MySQLCommunity Server and MySQL Workbench running on Ubuntu 18.04 with only one user account. I installed both the server and workbench using apt and used the guide created by DevAnswers.co here.
After installing the server and workbench I attempted to access the server using the workbench BEFORE I ran the sudo mysql_secure_installation command. I got the same two errors. I then ran the secure installation command and assigned a password which I do remember and did input into the password field of mySQL workbench albeit with the same results. I am very new to mySQL and databases and am trying to install mySQL to learn how to use SQL. I'd appreciate any help you all can provide in resolving this issue.
Additional pictures:
and .
I suspect that you just need to follow this short guide to set a root password:
https://whs-dot-hk.github.io/ubuntu-18.04/install-mysql.html
After setting a root password, you should be able to connect to mysql-workbench.
In short the root user in MySQL is authenticated using an auth socket, not a password. That's what's giving the message you're getting in the first screenshot.
(I'm assuming this is for a development project, for a production project you should keep the default config)

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

Mac OS Yosemite : How to start mysql and connect Sequel Pro?

I have just installed MySQL using the installation documentation.
MySQL is installed in the directory /usr/local as indicated in the documentation.
I attempted to start MySQL using the following command on the command line:
/Library/StartupItems/MySQLCOM/MySQLCOM start
Is it normal that I did not receive a message in the terminal that MySQL has started.
Where is the configuration file location (where do I find the root user account)?
After running the MySQL start command, I launched Sequel Pro, but I cannot connect to 127.0.0.1. How can I connect to this? Here is a screenshot of what happens when I attempt to connect:
I would just like to to start mysql and connect a gui client, what am I missing?
you need to be root to start the service.
type sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
MySQL is configured to listen to port 3307 when installed on Yosemite. After you verify that effectively you started the service, change the Port parameter on your Sequel Pro access window and try again.

MySQL Error on Mac Lion 10.7

I am trying to make mysql run on mac so I can make it work with rails 3. I installed the mysql*.dmg file from the official website, and I have also added this in my ".bashrc" file:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
PATH=$PATH:/usr/local/mysql/bin
Now I have created a /tmp/mysql.lock file, changed its permission and I still get this error when I am trying to run mysql:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)
Any help installing mysql on Lion?
That's because MySQL is probably creating the socket file somewhere else. Use
mysqladmin variables
in the terminal to find out the exact location and use it in your database.yaml.