I have installed LAMP on my Ubuntu machine.
Where Apache2 and PHP5 have been installed properly as when I run apache2 -v
and php5 -v
I am getting their installed versions.
But I am not sure how do I check If My-SQL
is properly installed or not.
Because when I run mysql -u root -p
command, I am getting the below error.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Please help!
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
"Try" to run mysql via /etc/init. d/mysql start if it gives you the exact same error from above then you need to copy the mysql. server file from the mysql you downloaded which can be found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and copy it to /etc/init.
It means either the MySQL server is not installed/running, or the file mysql. sock doesn't exist in /var/lib/mysql/ . There are a couple of solutions for this error. Then try to connect again.
For resolving this issue, you need to run following commands sequentially
sudo service mysql stop
sudo /etc/init.d/apparmor reload
sudo service mysql start
After that you can run the following command to go to mysql console
mysql -u root -p
mysql>
you could try starting your mysql first
> ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
>
> service mysql start or service mysql start
try to force redefining the root password:
sudo service mysql stop
sudo /usr/bin/mysqld_safe --skip-grant-tables &
mysql -h localhost
(now we are using mysql without carring to user privileges)
> USE mysql
> UPDATE mysql.user
SET authentication_string=PASSWORD('new_password')
WHERE user='root' AND host='localhost';
> quit
sudo mysqladmin shutdown
sudo service mysql start
that's all ... now try to use mysql with the new password, like that:
mysql -uroot -p
Enter password: enter the new_password
it should work :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With