Installed mysql#5.6 using brew mysql.server not a command - mysql

I installed mysql#5.6 using brew. Below are the comands I ran
brew install mysql#5.6
sudo chmod -R 777 /usr/local/var/mysql
sudo ln -s /usr/local/Cellar/mysql\#5.6/5.6.41/bin/mysql /usr/local/bin/mysql
sudo cp /usr/local/Cellar/mysql\#5.6/5.6.41/homebrew.mxcl.mysql.plist /Library/LaunchAgents/
sudo chown root /Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo chmod 600 /Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo chmod +x /Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load -w /Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysql.server start
sh: mysql.server: command not found
this is the output I am getting.
mysql --version is giving output
mysql Ver 14.14 Distrib 5.6.41, for osx10.13 (x86_64) using EditLine
wrapper
If I start service via brew its starting
brew services start mysql#5.6
But when I run mysql -uroot I am getting
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2)

I think you need to start the service as well:
brew services start mysql#5.6
You can then check so the mysql service is running using:
brew services list
Now try to create symlinks for the mysql package:
brew link --force mysql#5.6
You might need to add the location to mysql to your path, to find the location of the package:
brew list mysql#5.6
Then add the location to the bin folder to the end of your ~/.profile or ~/.bash_profile file. For instance:
export PATH=$PATH:/usr/local/Cellar/mysql#5.6/5.6.41/bin
Then reload the file:
source ~/.bash_profile
Now you should be able to use the mysql and connect to the local running server.

$ vi ~/.bash_profile
write
PATH=${PATH}:/usr/local/mysql/bin
PATH=${PATH}:/usr/local/mysql/support-files
in it.
save it.
$ source ~/.bash_profile
and then try mysql.server start

Related

mysql.server start wont start the mysql server

Whenever I type "mysql.server start" on OSX terminal I get this error:
Maria-MacBook-Pro:~ mariakocsis$ mysql.server start
Starting MySQL
./usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 647: /var/lib/mysql/Maria-MacBook-Pro.local.err: No such file or directory
Logging to '/var/lib/mysql/Maria-MacBook-Pro.local.err'.
2018-05-31T12:12:39.6NZ mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 144: /var/lib/mysql/Maria-MacBook-Pro.local.err: No such file or directory
ERROR! The server quit without updating PID file (/var/lib/mysql/Maria-MacBook-Pro.local.pid).
Maria-MacBook-Pro:~ mariakocsis$ sudo chmod -R 777 /usr/local/mysql/
chmod: /usr/local/mysql/: No such file or directory
Maria-MacBook-Pro:~ mariakocsis$
Even if I try to run mysql by MAMP, its not working.
Before the error I followed this commands:
cd ; nano .bash_profile
/usr/local/mysql/bin/mysql -v
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe ; exit;
source ~/.bash_profile mysql -v
in your terminal type in: mysql
source ~/.bash_profile mysql -v
SHOW GLOBAL VARIABLES LIKE 'PORT';
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7
sudo nano /etc/my.cnf
How can I reset this things?
And how I can start mysql server?
Use command below:
To start mysql: mysqld start
To stop mysql: mysqld stop
To restart: mysqld restart

How to stop mysql on OsX from the command line

This question bas many answers, I tried what I found – did not work
So, I tried sudo mysqld stop.
Still I see the mysql processes running:
0 317 1 0 11:15AM ?? 0:00.02 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
74 3562 317 0 11:40AM ?? 0:00.41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.err --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
The same happens if I do “sudo kill -9 3562”.
Trying to go to /Library/LaunchDaemons does not retrieve any mysql entries
ls /Library/LaunchDaemons | grep mysql
The service command does not work:
-bash: service: command not found
My Os X version is 10.9.2
There are two answers I know, it might not help since you search a long time.
1.if you install mysql from dmg, you can close it in "system preferences".
2.And besides that, you can start/stop/restart mysql by:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart
To install Homebrew, open Terminal/iTerm and run following command or check https://brew.sh/
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install mysql
$ brew install mysql.
Install brew services first
$ brew tap homebrew/services.
Start mysql
$ brew services start mysql.
In order to avoid mysqld from auto restarting after killed, try execute all these 3 commands:
$ brew services stop mysql
$ sudo launchctl unload /Library/LaunchDaemons/com.mysql.mysql.plist
$ sudo launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

mysql - installing or upgrading mysql 5.5 to 5.6 in Linux mint

Following error message getting while upgrading from Mysql 5.5 to 5.6.
The following packages have unmet dependencies:
mysql-client-5.6 : Depends: mysql-client-core-5.6 but it is not going to be installed
mysql-server-5.6 : Depends: mysql-server-core-5.6 (=
5.6.19-0ubuntu0.14.04.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I had the same problem which was solved after update and upgrade.
Try this, I hope this works for you:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install mysql-server-5.6
Installing MySQL 5.6 on Linux(debian based distro):
Uninstall any existing version of MySQL:
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-*
mysql-client-core-*
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
Automatically uninstall mysql:
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
Download version 5.5.51 from MySQL site
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Add mysql user group:
sudo groupadd mysql
Add mysql (not the current user) to mysql user group:
sudo useradd -g mysql mysql
Extract mysql-5.6.*-linux2.6-x86_64.tar.gz to /usr/local:
cd /usr/local
sudo tar -xvf mysql-5.6.*-linux2.6-x86_64.tar.gz
Create mysql folder in /usr/local:
sudo mv mysql-5.6.*-linux2.6-x86_64 mysql
Set mysql directory owner and user group:
cd mysql
**sudo chown -R mysql:mysql * **
Install the required lib package:
sudo apt-get install libaio1
Execute mysql installation script:
sudo scripts/mysql_install_db --user=mysql
Set mysql directory owner from outside the mysql directory:
sudo chown -R root .
Set data directory owner from inside mysql directory:
sudo chown -R mysql data
Copy the mysql configuration file :
sudo cp support-files/my-medium.cnf /etc/my.cnf
Start mysql:
sudo bin/mysqld_safe --user=mysql &
sudo cp support-files/mysql.server /etc/init.d/mysql.server
Initialize root user password:
sudo bin/mysqladmin -u root password 'test'
Start mysql server:
sudo /etc/init.d/mysql.server start
Stop mysql server
sudo /etc/init.d/mysql.server stop
Check status of mysql:
sudo /etc/init.d/mysql.server status
Enable myql on startup:
sudo update-rc.d -f mysql.server defaults
Add mysql path to the system:
sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
Now directly use the command below to start mysql
mysql -u root -p

Install MySQL 5.5 in Ubuntu 11.10

I have been downloaded the DEB package of mysql 5.5.23.
Install MySQL by the command as follows:
sudo dpkg -i mysql-5.5.23-debian6.0-x86_64.deb
The result said that installed successfully.
But when I type the command:
sudo service mysql start
Or
mysql
It shows me that "mysql: unrecognized service" or "mysql: command not found".
Besides, I can't find MySQL files in "/usr/include" or "/usr/bin"
Please help me. Thx.
Because MySQL 5.5.x is not packaged, in repositories only exist 5.1.x
This worked for me:
http://www.rebojo.com/debian-installing-mysql/
Why not a simple command :
sudo apt-get install mysql-server
MySQL Download URL
https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Open the terminal and follow along:
Uninstall any existing version of MySQL
sudo rm /var/lib/mysql/ -R
Delete the MySQL profile
sudo rm /etc/mysql/ -R
Automatically uninstall mysql
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
Download version 5.5.51 from MySQL site
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Add mysql user group
sudo groupadd mysql
Add mysql (not the current user) to mysql user group
sudo useradd -g mysql mysql
Extract it
sudo tar -xvf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Move it to /usr/local
sudo mv mysql-5.5.56-linux-glibc2.5-x86_64 /usr/local/
Create mysql folder in /usr/local by moving the untarred folder
cd /usr/local
sudo mv mysql-5.5.49-linux2.6-x86_64 mysql
set MySql directory owner and user group
cd mysql
sudo chown -R mysql:mysql *
Install the required lib package (works with 5.6 as well)
sudo apt-get install libaio1
Execute mysql installation script
sudo scripts/mysql_install_db --user=mysql
Set mysql directory owner from outside the mysql directory
sudo chown -R root .
Set data directory owner from inside mysql directory
sudo chown -R mysql data
Copy the mysql configuration file
sudo cp support-files/my-medium.cnf /etc/my.cnf
Start mysql
sudo bin/mysqld_safe --user=mysql &
sudo cp support-files/mysql.server /etc/init.d/mysql.server
Set root user password
sudo bin/mysqladmin -u root password '[your new password]'
Add mysql path to the system
sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
Reboot!
Start mysql server
sudo /etc/init.d/mysql.server start
Stop mysql server
sudo /etc/init.d/mysql.server stop
Check status of mysql
sudo /etc/init.d/mysql.server status
Enable myql on startup
sudo update-rc.d -f mysql.server defaults
*Disable mysql on startup (Optional)
`sudo update-rc.d -f mysql.server remove`
REBOOT!
Now login using below command, start mysql server if it's not running already
mysql -u root -p

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