I can't start MySQL Server and Workbench error - mysql

I have just installed MySQL and MySQL Workbench.
After installing both, I can see the "MySQL" icon in System Preferences. But if I try to start MySQL Server it asks me the password, but then nothing happens.
So I tried to start MySQL Server from the terminal with the following command:
sudo /usr/local/mysql/support-files/mysql.server start
But it gave me this error:
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/MBP.local.pid).
Can anyone help me please?
Before all this I've not had any problems starting and stopping MySQL, but I forgot the MySQL password so I had to uninstall MySQL and install it again because I needed to use Workbench. But obviously without the MySQL password it didn't work. Is there a way for me to recover the password?

Check if a mysql process already exists or not ps -ef | grep mysql
If yes, Kill the process kill -9 PID or killall -9 mysql mysqld
Check the owner ship of the mysql data directory is mysql:mysql
Then try to start mysql server sudo mysql.server start
If this do not resolve the issue. Then have a look in the mysql .err file
Check out: MySql ERROR! The server quit without updating PID file

The sudo line will try to run MySQL as root -- bad idea. Hopefully the mysql.server file was copied to /etc/init.d during install so all you should have to do is /etc/init.d/mysqld start

Related

unable to stop mysql server on macos terminal after log on as root user

i am using a macos to run mysql on the terminal.
what i usually do is:
mysql.server start
mysql -u root -p
then mysql is okay to be used, for creating database, tables and etc.
but when i want to shut down mysql server. it will give me error message that my syntax is wrong.
mysql.server stop
May i ask if anyone has a similar issue before?
Thank You
I will terminate the terminal then type
mysql.server stop
and it will shut down successfully.
i am hoping i dont need to keep terminating my terminal before i can shut down mysql server.
mysql.server stop will only work from shell.
If you started the command line client mysql and you want to stop the server, either use the SQL command
SHUTDOWN
to shutdown your MySQL server (this requires shutdown privilege). Or execute system shell command with \!:
\! mysql.server stop.

MySQL Database starts on Terminal But not on XAMPP

I am trying to start MySQL Database on XAMPP, and it doesn't start.
But when I ran this on my terminal:
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
The terminal gives me a success message.
How can I check if MySQL Database is actually running?
And how can I make the status on XAMPP say Running and not Stopped?
Thank you!
But when I ran this on my terminal:
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
The terminal gives me a success message.
How can I check if MySQL Database is actually running?
And how can I make the status on XAMPP say Running and not Stopped?
Thank you!
try to use this command:
sudo service mysql status
Use one of the commands to check mysql running on Linux.
mysqladmin -u root -p status
if mysql running it will display output uptime and queries else you get failed error
sudo service mysqld status OR # /etc/init.d/mysqld status
For Ubuntu use service mysql status

Resetting MySQL password & missing mysqld.sock file

I am trying to run a local mysql server, on my own computer. I have lost the password that I initially set up. When I try to connect to mysql, I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I have therefore tried these steps to reset my MySQL password, but the line
mysql -u root mysql
returns the same error message:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
When running the command
mysqladmin -u root -p status
I get the following message:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I have been checking and the file mentioned (/var/run/mysqld/mysqld.sock) doesn't actually exist. I am not sure what is causing this.
I have tried a couple of solutions online including this, this, this and this but none of this solutions worked for me. I would like to add that mysql-server is installed on my machine.
Any help appreciated. Please accept my apologies if there is any confusion to the above statements. I tried to explain what is happening as much as I can, but I am a beginner and I am clueless as to what is happenening there.
1) Stop the mysql demon process using this command :
sudo /etc/init.d/mysql stop
2) Start the mysqld demon process using the --skip-grant-tables option with this command
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Because you are not checking user privs at this point, it's safest to
disable networking. In Dapper, /usr/bin/mysqld... did not work.
However, mysqld --skip-grant-tables did.
1) start the mysql client process using this command
mysql -u root
2) from the mysql prompt execute this command to be able to change any password
FLUSH PRIVILEGES;
3) Then reset/update your password
SET PASSWORD FOR root#'localhost' = PASSWORD('password');
4) If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
once have received a message indicating a successful query (one or more rows affected), flush privileges:
FLUSH PRIVILEGES;
Then stop the mysqld process and relaunch it with the classical way:
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
This is borrowed from https://help.ubuntu.com/community/MysqlPasswordReset , you can check also another method to reset mysql password.
Looks like your MySQL server is not running at all.
Can you check it?
service mysql status
You need to try restart it and make sure that you can stop and start it using
service mysql stop
service mysql start
If you have any errors post them here please.
Reinstalling mysql-server worked for me. (I am using mysql 5.7)
sudo wget http://repo.mysql.com/mysql-apt-config_0.8.9-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation
first kill user
sudo pkill -u <user>
Then install mysql server
sudo apt install mysql-server
Configure it
sudo mysql_secure_installation
Enter into mysql shell
sudo mysql

Installing xampp but phpmyadmin doesn't connect

So I installed xampp on my Linux machine running Ubuntu 14.04LTS. Now all of a sudden turns out when I try to connect to phpmyadmin it refuses to connect. I have already installed mysql separately as well but it doesn't seem to work. Any workaround for this?
The error that I get is :
MySQL said:
Cannot connect: invalid settings.
Connection for controluser as defined in your configuration failed.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Any reason why this happens and solution to it?
Go to http://localhost/security/ and then click on the link http://localhost/security/xamppsecurity.php.
After that change password for superuser to 'root'.
After that open your http://localhost/phpmyadmin/
As per the comment by RiggsFolly I was running two instances of MySQL
So both mysql servers do end up messing with phpmyadmin and this is how you shutdown the external mysql server while using xampp's inbuilt mysql server to connect successfully using phpmyadmin:
Use whichmysql to find the utility that is running
Navigate to the directory where the external MySQL service is running:
$ cd /usr/bin
$ mysqladmin shutdown
This shuts down the MySQL service running if at all it is running.
$ sudo service mysql stop
This helps as well if at all it will tell you the status of the service if it is already shut down.
Now we need to stop the Xampp mysql server so we navigate to /lampp/bin and again execute the same command to shut mysql server down.
$ cd /opt/lampp/bin
$ mysqladmin shutdown
Simply restart xampp and you should be good to go.
$ sudo /opt/lampp/lampp restart
I just fell into the same error. The solution I used was, stopping all the servers of xampp, exiting the program. Starting and stoping mysql then starting xampp again
Initial procedure before starting xampp:
sudo service mysql stop
sudo /etc/init.d/apache2 stop
If it bring the error as stated in this question, then follow the procedure below.
That is:
sudo /opt/lampp/lampp stop
sudo service mysql start
sudo service mysql stop
sudo /opt/lampp/lampp start

MySQL not working on Ubuntu 11.04

I run the mysql command at the command line but I get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I've Googled a lot but I'm unable to resolve the issue.
Please HELP!
It sounds like mysql isn't running. This will tell you if it is or not:
sudo netstat -tap | grep mysql
That's because the path you specified doesnt have the socket required to connnect to the mysql. This problem has happened with me. Either you can reinstall mysql or search for the mysqld.sock and then move it to the specified directory.
Try running this command to start the mysql server
/etc/init.d/mysql start
/etc/init.d/mysql restart