Can't start mySQL - mysql

Even after I reset the root password with the following command I can not log to MySQL: (other commands listed to provide additional info)
# sudo dpkg-reconfigure mysql-server-5.1
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
# telnet 127.0.0.1 3306
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
# ps -Aw |grep mysql
26522 ? 00:00:00 mysqld
# /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
update:
# sudo mysqladmin -u root password 123
mysqladmin: connect to server at 'localhost' failed
it seems MySQL is not running properly
Update:
I am using MySQL 5.1 under Ubuntu.
It was OK until that I make some change in my.cnf to enable Remote Access. I undo my changes but problems did not solved! (Perhaps I forgot to undo some thing!)
update:
# service mysql status
mysql start/running, process 26650
# /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 26650

to set root password:
mysqladmin -u root password NEWPASSWORD
To recover it:
http://www.cyberciti.biz/tips/recover-mysql-root-password.html

My best guess is that if you have reconfigured / reinstalled MySQL, you need to login without a password, e.g.:
mysql -u root
or even
mysql
Edit: To see if the service is running, you could try:
service mysqld status
and if it is not running, try:
service mysqld start then check the status again.

It seems like MySQL is definitely not running. You can verify this with /etc/init.d/mysqld status or service mysqld status (don't link directly to the service command).
My spidey sense is telling me either your O/S or MySQL installation were performed improperly. It would help tremendously to know more about the (linux?) environment you're running, and how it was configured (or who configured it, in the case of PaaS).

Start as a service
sudo service mysql restart
to verify & check the service and the port
sudo netstat -tap | grep mysql

you should change the access permission. it should be 0644
sudo chmod 644 /etc/mysql/my.cnf
and then
sudo dpkg-reconfigure mysql-server-5.5

Related

docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:3306: bind: address already in use

Am getting this error in the terminal when setting up a container.
Eventually the database does initialise:
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Initialized Database
But I then have trouble accessing it from the root user which makes me think the container isn't working properly.
This is pretty common error. As #danblack already enlightened in comments, mysql is already running on host port 3306. There are two ways to solve this error (for linux)
kill mysql demon on host and then run docker container again.
$ sudo service stop mysql
$ docker run --name=test-mysql mysql
run mysql container on different port
$ docker run --name=test-mysql -p 3305:3306 mysql
This worked for me in freeing up port 3306 used up by MySQL service
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Try this and try to load back your mySQL service up again using
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

Warning: mysql_connect(): Can't connect to local MySQL server through socket

My WordPress site ( http://steamboatperinatalconference.com ) just recently started going down and spitting this error
" Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/www/html/wp-includes/wp-db.php on line 1568 "
I have checked the db password and its ok, also reset the instance and sql server and both are running, I'm able to connect to my database through mysqlworkbench.
Not sure why my website won't display if the database is up and running.
Any help is appreciated.
First kill the processes with:
sudo pkill mysql
and
sudo pkill mysqld
restart mysql
sudo service mysql restart
now you should be able to log in
mysql -u root -p
It turns out in order to fix the issue I was having I needed to run a sudo yum update on the AWS ec2 instance, after performing the update the page was back up and running
my.cnf (location of file /etc/mysql/ folder) configured with
socket=/var/lib/mysql/mysql.sock
check for MySQL is running with the following command:
mysqladmin -u root -p status
changing permission to MySQL folder. If you are working locally, you can try:
sudo chmod -R 755 /var/lib/mysql/

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

How to stop and start the mysql?

When I'm use the find command to locate the MySQL location, it returns the below paths. But, I want to restart the MySQL. If I stop the path (/usr/bin/mysql) it shows the error
[Access denied to user 'root'#'localhost' with password='NO]'
so, Which MySQL will be get restart in the below paths ?
/usr/bin/mysql
/usr/share/mysql
/usr/lib/mysql
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/DBD/mysql
/usr/lib64/mysql
/var/lib/mysql
/var/lib/mysql/mysql
to stop mysql account is:
sudo mysqladmin -h localhost -u root -p shutdown
to start is:
sudo systemctl start mysql.service
to confirm:
sudo mysql -h localhost -u root -p
NB:
the default password for root account is root
**not sure but i think this closes connection for all accounts & also starts for all accounts though you have stop using an account with privilege access/root access by using the grant statement.
example
GRANT ALL PRIVILEGES ON databasename.* TO 'username'#'localhost';
source http://www.luciopanasci.it/Ebooks/MySQL%20Cookbook,%203rd%20Edition.pdf
page 2 topic 1.1**
As root, run
service mysqld restart
If that does not work, try
/etc/init.d/mysqld restart
Instead of restart you can use :
start to start mysql
stop to stop it
Usually you do
/etc/init.d/mysql start/stop/restart
It may be called mysqld or mysql-server or something like that. If you're on Ubuntu, you have to do
service mysql start/stop/restart
there it may be mysqld or mysql-server or something like this as well.
If Mysql is running as a service:
sudo service mysql restart;
or
sudo service path/to/mysql restart;
Edit:
check if mysql is running
service --status-all
service --status-all | grep mysql
If Mysql is running, use
To Restart: service mysqld restart
Other command which can be used if necessary are given below.
To Stop: service mysqld stop
To Start: service mysqld start

Cannot log in to mysql after default install with Macports

I've installed mysql5 using Macports and the installation appears to check out but I cannot login to the server at all.
This is what I did:
sudo port install mysql5-server
This builds and installs fine.
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
This runs fine as well. It outputs the following:
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h LeoMacBook.local password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!
Now...let's follow the instructions exactly. I start the server:
sudo /opt/local/lib/mysql5/bin/mysqld_safe &
Server is running fine.
When I try to change the root password, I CANNOT log in.
LeoMacBook:bin leonardteo$ /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
I'm at wits end.
I've started the server with --skip-grant-tables. With this, I can load up mysql fine from the command line and I'm connected to the server. When I run SELECT * FROM mysql.user;, it returns an empty set! With this, I've tried to create a new user by invoking the command:
CREATE USER 'root'#'localhost' IDENTIFIED BY 'root';
But this doesn't work. I get the error:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
I cannot get this working. It seems I am so close, yet the root user seems to be missing.
Any ideas?
Leonard
Once you've started up mysql with --skip-grant-tables, issue a flush privileges; query. This'll re-enable the permissions system and allow you to run the usual grant and create user queries.