Install MySQL and create a database on Mac OS X Yosemite - mysql

I want to install MySQL on Mac OS X Yosemite, create a new user, then create a new database called "my_database". How can I do this?
What I've tried:
From command line, brew install mysql. This succeeds and downloads
MySQL to /usr/local/bin/mysql.
Log into MySQL mysql -u root.
I get an error in Step 2:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)`
I'm not sure how to fix this. I ran ps ax | grep mysql which showed no MySQL processes were running. Then I ran sudo /usr/local/bin/mysql start but I get the same ERROR 2002 (HY000): Can't connect to local MySQL ....

You may need to update your path to the mysql socket.
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
I think this was already answered here:
Mysql won't start after upgrading Mac OS X Yosemite (Mac OS 10.10)

Related

WSL2 /ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)

sorry for my english
I try to install zabbix in a ubuntu 20.04 who is running in a WSL Windows10 ( for school training)
When i try to connect to mariadb ,this message appear:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
i saw similar questions , in the forum but i don't find anyone who specificly talk about WSL.
thank you for helping!
This issue occurs in WSL because mysql or mariadb is installed but is not running yet.
Use sudo /etc/init.d/mysql start to start the server.
If this doesn't work you might also had an error during installation because it couldn't set the runlevel.
In my case I had to deinstall mysql/mariadb and install it as follows:
sudo su
export RUNLEVEL=1
apt install mysql-server
/etc/init.d/mysql start

Can't connect to MySQL installed via Homebrew on Mac Monterey

I ma using M1 MacBook Air, and managing my tools with Homebrew.
I've installed Mysql, and it was working fine for a while, but when I've rebooted my device it just stopped working.
I don't get any errors when running brew services start mysql, but when I try brew services list MySQL is marked as stopped.
When I try to enter mysql with mysql -u user -p password I get following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
When I run mysql.server start (as some answers suggest) I get following error:
. ERROR! The server quit without updating PID file (/opt/homebrew/var/mysql/MacBook-Air.local.pid).
I've tried many solutions, but non of them worked.
i fixed this error The server quit without updating PID on mysql version 8.0.18
try sudo chown -R mysql:mysql xx/mysql, and sudo chmod 775 xx/mysql
'xx/mysql' is your mysql home dir

MySQL: Cannot connect to MySql on Sequel Pro after 5.5 to 5.7 upgrade

I have upgraded my MySql Server from 5.5 version to 5.7 version. While using 5.5 version, I could connect via mysql -u #user -p#pass command in terminal or using Sequel Pro (management system).
I have upgraded version by:
$ wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb
$ sudo apt-get update && sudo apt-get install mysql-server
Now at 5.7 version I can still log in into MySql with root user using terminal (same settings as one on 5.5 version), but Sequel Pro refuses to connect with error:
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary
privileges, or try increasing the connection timeout (currently 10
seconds).
MySQL said: Lost connection to MySQL server at 'reading initial
communication packet', system error: 0
I got debian under vagrant on mac os.
I have succeeded following
MySQL root access from all hosts
answer under b).
Note:
Update For Ubuntu 16:
Config file is (now)
/etc/mysql/mysql.conf.d/mysqld.cnf

Cannot get MySQL running in Terminal on macOS Sierra

I have been setting up a new laptop for development purposes and when trying to get MySQL to run in the Terminal I get the following message:
$ mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Can somebody please help me out here?
You may get this error because mysql server is not started. For me it solved only by starting mysql server.
to start Mysql server (for Mac OS X), command line in terminal:
sudo /usr/local/mysql/support-files/mysql.server start
or, simply go to your Mac System Preference --> MySQL --> click on start mysql..

MySQL doesnt run on OSX after intall -- Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I have a fresh OSX (Yosemite) installation i installed mysql using the following command
brew install mysql
Post installation it asked me to run the following command
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
After closing the iTerm and restarting when i try to access MySQL i get the following error
➜ ~ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I think you may just need to start/restart mysql now.
Try
mysql.server restart