mysql.server start wont start the mysql server - mysql

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

Related

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

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

Cannot Start MYSQL Server Mac

I am currently trying to run mysql server on a mac, but the Start MySQL Server from the preferences pane doesn't work, and neither does starting it from the Terminal. I have found a lot of fixes, but none of them work. This is my first time using MySQL, I have very little (just a bit of Java) programming experience, and this is my first StackOverflow post in a long time (please help me learn if I did it incorrectly!).
I installed this version(didn't use brew): mysql-5.7.21-1-macos10.13-x86_64
My machine is 64 bit
What I've tried:
Uninstalled and reinstalled MySQL using this process:
To uninstall MySQL and completely remove it (including all databases) from your Mac do the following:
Open a terminal window Use mysqldump to backup your databases to text
files! Stop the database server sudo rm /usr/local/mysql sudo rm -rf
/usr/local/mysql* sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm
-rf /Library/PreferencePanes/My* edit /etc/hostconfig and remove the line MYSQLCOM=-YES- rm -rf ~/Library/PreferencePanes/My* sudo rm -rf
/Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm
-rf /private/var/db/receipts/mysql https://community.jaspersoft.com/wiki/uninstall-mysql-mac-os-x
When I open the folder where mysql is installed, I do not have permissions to open the data or keychain folders. So, I decided it was a permissions problem and tried this: Cannot start Mysql on Mac. When I tried to start the server, I got the following error:
sudo /usr/local/mysql/support-files/mysql.server start Starting MySQL
.Logging to '/usr/local/mysql/data/XXXXs-MacBook-Air.local.err'.
/usr/local/mysql/bin/mysqld_safe: line 198: 7892 Trace/BPT trap: 5
nohup /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=XXXXs-MacBook-Air.local.err --pid-file=/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid < /dev/null > /dev/null 2>&1 ERROR! The server quit without updating
PID file (/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
Tried to check the admin version and got the following error:
XXXXs-MacBook-Air:mysql XXXX$ bin/mysqladmin version 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!
Tried to open /temp/mysql.sock from the command line and got that it does not exist
Tried this:
XXXXs-MacBook-Air:mysql XXXX$ % mysqladmin variables
-bash: fg: %: no such job XXXXs-MacBook-Air:mysql XXXX$ mysqladmin variables
-bash: mysqladmin: command not found
Tried removing my.cnf per this post and restarted the server
sudo rm -rf /etc/my.cnf
sudo /usr/local/mysql/support-files/mysql.server start
Tried these instructions MySql server startup error 'The server quit without updating PID file '
XXXXs-MacBook-Air:mysql XXXX$ ps -ef | grep mysql 501 9173
549 0 11:54PM ttys000 0:00.01 grep mysql
XXXXs-MacBook-Air:mysql XXXX$ kill -9 PID
-bash: kill: PID: arguments must be process or job IDs XXXXs-MacBook-Air:mysql XXXX$ ls -laF /usr/local/var/mysql/ ls:
/usr/local/var/mysql/: No such file or directory
XXXXs-MacBook-Air:mysql XXXX$ ls -laF /usr/local/mysql lrwxr-xr-x
1 root wheel 30 Apr 4 22:44 /usr/local/mysql# ->
mysql-5.7.21-macos10.13-x86_64 XXXXs-MacBook-Air:mysql XXXX$ sudo
chown -R mysql /usr/local/var/mysql/ Password: chown:
/usr/local/var/mysql/: No such file or directory
XXXXs-MacBook-Air:mysql XXXX$ sudo chown -R mysql /usr/local/mysql
XXXXes-MacBook-Air:mysql XXXX$ sudo
/usr/local/mysql/support-files/mysql.server start Starting MySQL
.Logging to '/usr/local/mysql/data/XXXXs-MacBook-Air.local.err'.
/usr/local/mysql/bin/mysqld_safe: line 198: 9327 Trace/BPT trap: 5
nohup /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=XXXXs-MacBook-Air.local.err --pid-file=/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid < /dev/null > /dev/null 2>&1 . ERROR! The server quit without updating
PID file (/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
XXXXs-MacBook-Air:mysql XXXX$ unset TMPDIR
XXXXs-MacBook-Air:mysql XXXX$ mysql_install_db --verbose
--user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
-bash: mysql_install_db: command not found
And now I'm back to this error:
ERROR! The server quit without updating PID file
(/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
Please help!
EDITED: I uninstalled and reinstalled with brew. Using these instructions: http://stefan.magnuson.co/articles/osx/reinstalling-mysql-on-osx-with-homebrew/ Now it works.
I uninstalled and reinstalled SQL with Homebrew using these instructions: http://stefan.magnuson.co/articles/osx/reinstalling-mysql-on-osx-with-homebrew/ Now it works.
This small diagnosis worked for me in MAC...
open Your Terminal and use the following command to check all the instances or mysql that are currently running in your machine.
1) ps -ef | grep mysql
If you found any process Id with the above command.
2) sudo kill -9 [PID]
Where [PID] is the process id next to username
now try restarting mysql again using the mysql server pane or go to terminal and type the following command
sudo /usr/local/mysql/support-files/mysql.server start

mysql command line with xampp in ubuntu 14.04

I installed xampp. After I type sudo /opt/lampp/lampp start into terminal, I get
$ sudo /opt/lampp/lampp start
Starting XAMPP for Linux 5.6.23-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
I changed the root password in /opt/lampp/phpmyadmin/config.inc.php
The password in localhost/phpmyadmin agrees with the change made in the config.inc.php file.
When I type mysql -u root -p into terminal I get
The program 'mysql' can be found in the following packages:
* mysql-client-core-5.5
* mariadb-client-core-5.5
* mysql-client-core-5.6
* percona-xtradb-cluster-client-5.5
Try: sudo apt-get install <selected package>
I installed mysql-client-core-5.6
$ sudo apt-get install mysql-client-core-5.6
[sudo] password for experiment:
Reading package lists... Done
After installing the client, when I typed mysql -u root -p into terminal I got
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Some threads suggest that multiple instances of mysql could be running.
When I type ps ax | grep mysql into terminal, I get
$ ps ax | grep mysql
7021 ? S 0:00 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/experiment-MP061.pid
7168 ? Sl 0:02 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --plugin-dir=/opt/lampp/lib/mysql/plugin/ --user=mysql --log-error=/opt/lampp/var/mysql/experiment-MP061.err --pid-file=/opt/lampp/var/mysql/experiment-MP061.pid --socket=/opt/lampp/var/mysql/mysql.sock --port=3306
11112 pts/6 S+ 0:00 grep --color=auto mysql
I don't know how to interpret the output. Is this one instance of mysql?
Some threads suggest making changes to the my.cnf file. I don't have one. I do have a etc/mysql/my.cnf.bak file. Where should I put the my.cnf file?
Should I be able to use the mysql command line after installing xampp only or do I need to install a client?
My ultimate goal is to have a system where I can use xampp, Workbench, NetBeans, and the mysql command line.
To find the path where my.cnf or my.ini is picked up, issue a command
mysql --help
It will echo out a lot of info. Search thru the text to find a line like the following:
Default options are read from the following files in the given order:
C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf C:\Program Files\MySQL\MySQL Server 5.7\my.ini C:\Program Files\MySQL\MySQL Server 5.7\my.cnf
or
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
It is buried right in the middle of the echo output.
Lastly,
$ sudo netstat -tlpn | grep mysql
tcp6 0 0 :::3306 :::* LISTEN 10954/mysqld
port 3306.
If you have a few daemons running, you will get multiple lines. You use the -P (uppercase) switch at the cmd line for the port number. Note that lowercase -p is for the password (either prompt for it or give it)

Ubuntu: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I have a Ubuntu 14.04. server with LAMP installed where an Owncloud is running. I tried to install paperwork which didn't work out but thats not the problem.
After restarting my server I tried to access my owncloud again but I am facing an internal server error. See following picture.
Owncloud error
I looked in the log /var/log/apache2/error.log and theres following phrase:
Lost connection to MySQL server during query' in ...
I tried to restart the mysql service but this error appears:
stop: Unknown instance:
start: Job failed to start
Then I tried to login to mysql with mysql -u root -p and follorwing error appears:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I've looked for the sockets on the machine with find / -type s and the socket was there: /run/mysqld/ .
I created a symbolic link and pasted it to /var/run/mysqld/mysqld.sock
Unfortnutely nothing worked. After restarting again I can't find the socket anymore the output of find / -type s is:
/dev/log
/run/php5-fpm.sock
/run/udev/control
find: `/proc/977/task/977/fd/5': No such file or directory
find: `/proc/977/task/977/fdinfo/5': No such file or directory
find: `/proc/977/fd/5': No such file or directory
find: `/proc/977/fdinfo/5': No such file or directory
Update
I've reinstalled the server so problem is over :D
If you install lampp server, run mysql first
sudo /opt/lampp/lampp startmysql
Then make "mysqld" directory in /var/run
cd /var/run
sudo mkdir mysqld
Link your mysql from lampp to /var/run/mysqld
sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock
run mysql -u root -p . hope may help you
If you install LAMPP server, run MySQL first
sudo /opt/lampp/lampp startmysql
Then make "mysqld" directory in /var/run
cd /var/run
sudo mkdir mysqld
Link your mysql from lampp to /var/run/mysqld
sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock
run MySQL
mysql -u root -p .
If MySQL fails with «mysql» not found, install:
sudo apt install mysql-client-core-5.7
sudo apt install mariadb-client-core-10.1
There is any issues with the mysql services. Please try to restart mysql services and check the mysql error logs for more information

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