MySQL installed with Brew is refusing to start - mysql

I've installed mysql using brew:
MacBook-Air-Pavel:mysql paus$ sudo brew install mysql
==> Installing mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.6.24.yosemite.bottle.tar.gz
######################################################################## 100,0%
==> Pouring mysql-5.6.24.yosemite.bottle.tar.gz
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
==> Summary
🍺 /usr/local/Cellar/mysql/5.6.24: 9719 files, 338M
Unfortunately, when I'm trying to staet mysql.server, it crashes with this message:
MacBook-Air-Pavel:webogram paus$ mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Air-Pavel.local.pid).
MacBook-Air-Pavel:webogram paus$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I've no idea why it happens. Could you help me to avoid this problem?
Thank you!

Related

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' . Error after installation

Errors
After running service mysqld status in Ubuntu 20.04, I get the error:
Unit mysqld.service could not be found.
And after running sudo mysql I get:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
Info
I've just installed MySQL with command
sudo apt-get install mysql-server.
There were no errors during installation. Reinstalling doesn't help. I've also tried to find problem in config files, but I don't have /etc/my.cnf. I am not sure, if it's ok.
systemctl start mysql does not help.
By the way, service mysql status works just alright and returns active status.
Resolved question.
Delete /usr/local/mysql, /usr/local/bin/mysql, /usr/bin/mysql
Reinstall MySQL by
sudo apt-get update
sudo apt-get install mysql-server

MySQL 5.7 installed via brew now getting ERROR! The server quit without updating PID file (/usr/local/var/mysql/dev_box.local.pid)

I had mysql version 8 earlier, due to some dependency i had to downgrade to 5.7 so installed mysql#5.7 via brew.
Steps
brew uninstall mysql
brew install mysql#5.7
mysql.server start
brew link mysql#5.7 --force
Now once i have stopped the server and now i want to restart it but i am getting
ERROR! The server quit without updating PID file (/usr/local/var/mysql/dev_box.local.pid).
When i do
mysqld --initialize
I am getting
[ERROR] --initialize specified but the data directory has files in it. Aborting.
[ERROR] Aborting
But when i try to start the server using services it's starting but i am not getting anything in the grep but when i do "brew services list" it's showing that server is started.
but i am not able to login
mysqladmin -u root password 'password'
This gives the error
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
I have tried almost everything from
MySql server startup error 'The server quit without updating PID file '
After MySQL install via Brew, I get the error - The server quit without updating PID file
With no luck, hoping for some quick help.
I had the same situation. What helped me is:
First uninstall mysql using brew
brew uninstall mysql
brew uninstall mysql#5.7
Then manually go through all folders in /usr/local/ and delete everything related to mysql.
For example, I had /usr/local/etc/my.cnf and my.cnf.default, so had to run rm -f /usr/local/etc/my*; also /usr/local/mysql-5.7.21-macos10.13-x86_64 and mysql-8.0.16-macos10.14-x86_64, so rm -rf /usr/local/mysql* and so on.
After this is done install using brew
brew install mysql#5.7
brew services start mysql#5.7

What's the correct way of installing MySQL on CentOS 6.6 on Compute Engine by Google?

I've been trying to install MySQL on CentOS 6.6 but with no good results. I have just created a new VM with these steps:
1.- sudo yum -y install mysql-server mysql
2.- sudo mysql -u root
RESULT .- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
also doing a "sudo service mysql start"
RESULT mysql: unrecognized service
Thanks mates !
Try
sudo /etc/init.d/mysqld start
or
sudo service mysqld start

MySQL connection error on Mac OS X 10.8.5

I have installed MySQL using Homebrew on my Mac running OS X 10.8.5. Whenever i start my mac, and try to connect to MySQL i get the following error
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error)
I then run the following commands and then im able to connect
mysqld stop
mysql.server start
But on restarting my computer again i get the same error as above and have to run those commands again. Any way to fix it permanently ?
Thank You.
If you like to have the mysql server start on startup and to do, you would run the following commands:
('5.6.10' is mysql version number. if you use another version, change it)
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.6.10/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

How to start MySQL server from command line on Mac OS Lion?

I installed mySQL on my Mac. Beside starting the SQL server with mySQL.prefPane tool installed in System Preferences, I want to know the instructions to start from command-line.
I do as follows:
After
su root
I start the mySQL server by command-line, but it produces an error as below:
sh-3.2# /usr/local/mysql/bin/mysqld
111028 16:57:43 [Warning] Setting lower_case_table_names=2 because
file system for /usr/local/mysql-5.5.17-osx10.6-x86_64/data/ is case
insensitive
111028 16:57:43 [ERROR] Fatal error: Please read "Security" section of
the manual to find out how to run mysqld as root!
111028 16:57:43 [ERROR] Aborting
111028 16:57:43 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
Simply:
mysql.server start
mysql.server stop
mysql.server restart
Try /usr/local/mysql/bin/mysqld_safe
Example:
shell> sudo /usr/local/mysql/bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
shell> bg
(Press Control-D or enter "exit" to exit the shell)
You can also add these to your bash startup scripts:
export MYSQL_HOME=/usr/local/mysql
alias start_mysql='sudo $MYSQL_HOME/bin/mysqld_safe &'
alias stop_mysql='sudo $MYSQL_HOME/bin/mysqladmin shutdown'
I like the aliases too ... however, I've had issues with MySQLCOM for start ... it fails silently ... My workaround is akin to the others ... ~/.bash_aliases
alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'
As this helpful article states:
On OS X to start/stop MySQL from the command line:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
On Linux start/stop from the command line:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
Some Linux flavours offer the service command too
# service mysqld start
# service mysqld stop
# service mysqld restart
or
# service mysql start
# service mysql stop
# service mysql restart
If you installed it with homebrew, the binary will be somewhere like
/usr/local/Cellar/mysql/5.6.10/bin/mysqld
which means you can start it with
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server start
and stop it with
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server stop
Edit: As Jacob Raccuia mentioned, make sure you put the appropriate version of MySQL in the path.
Maybe your mysql-server didn't start.
You can try
/usr/local/bin/mysql.server start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
make alias in .bash_profile
alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
and if you are trying to run as root use following safe mode
sudo ./bin/mysqld_safe
if you are still having issues starting, a recommended read:
mysql5.58 unstart server in mac os 10.6.5
For me this solution worked on mac Sierra OS:
sudo /usr/local/bin/mysql.server start
Starting MySQL
SUCCESS!
My MySQL is installed via homebrew on OS X ElCaptain. What fixed it was running
brew doctor
which suggested that I run
sudo chown -R $(whoami):admin /usr/local
Then:
brew update
mysql.server start
mysql is now running
If it's installed with homebrew try just typing down mysql.server in terminal and that should be it.
AFAIK it executable will be under /usr/local/bin/mysql.server.
If not you can always run following "locate mysql.server" which will tell you where to find such file.
If you have MySQL installed through Homebrew these commands will help you:
# For starting
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# For stoping
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
MySql server startup error 'The server quit without updating PID file '
if you have installed mysql from homebrew
close mysql server from preferences of mac
ps ax | grep mysql
#kill all the mysql process running
sudo kill -9 pid
which mysql
/usr/local/bin/mysql
Admins-MacBook-Pro:bin username$ sudo mysql.server start
Starting MySQL
. SUCCESS!
Admins-MacBook-Pro:bin username$ which mysql
/usr/local/bin/mysql
Admins-MacBook-Pro:bin username$ ps ax | grep mysql
54916 s005 S 0:00.02 /bin/sh
/usr/local/Cellar/mysql#5.7/5.7.27_1/bin/mysqld_safe --datadir=/usr/local/var/mysql --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55012 s005 S 0:00.40 /usr/local/Cellar/mysql#5.7/5.7.27_1/bin/mysqld --basedir=/usr/local/Cellar/mysql#5.7/5.7.27_1 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql#5.7/5.7.27_1/lib/plugin --user=mysql --log-error=Admins-MacBook-Pro.local.err --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55081 s005 S+ 0:00.00 grep mysql
On mac Big Sur and MySQL 5.7, I needed to stop/start with:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
and
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
This answer came from https://coolestguidesontheplanet.com/start-stop-mysql-from-the-command-line-terminal-osx-linux/
In my case, I had downloaded the mysql server and installed it but I didn't click on the run server that showed up on the last installer page.
In order to start my server manually in the terminal (without adding aliases), I used this in the terminal and it works.
Start Server:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Stop Server:
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
More info at the link below:
https://www.databasestar.com/start-mysql-server/
111028 16:57:43 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
Have you set a root password for your mysql installation? This is different to your sudo root password. Try /usr/local/mysql/bin/mysql_secure_installation