I try to stop mysql but anything I do nothing happens
I checked my database:
~$ mysql --version
mysql Ver 15.1 Distrib 10.0.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
It shows that Im using MariaDB ok... So I tried to stop it and...
$ sudo systemctl stop mariadb
Failed to stop mariadb.service: Unit mariadb.service not loaded.
mariadb.service not loaded? why?
I tried to stop database with this command:
sudo systemctl stop mysql
I got no error.
but my website still works. It means database is running.
when I print out status of mysql:
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since wto 2018-04-24 00:32:29 CEST; 9min ago
Docs: man:systemd-sysv-generator(8)
Process: 2062 ExecStop=/etc/init.d/mysql stop (code=exited, status=1/FAILURE)
Process: 1988 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mysql.service
├─1459 /bin/bash /usr/bin/mysqld_safe
├─1608 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-log-error --pid-file=/var/r
└─1609 logger -t mysqld -p daemon error
kwi 24 00:32:29 bla-Z68A-D3H-B3 mysql[2062]: * Stopping MariaDB database server mysqld
kwi 24 00:32:29 bla-Z68A-D3H-B3 mysql[2062]: ...fail!
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: mysql.service: Control process exited, code=exited status=1
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: mysql.service: Unit entered failed state.
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: mysql.service: Failed with result 'exit-code'.
kwi 24 00:33:21 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:36:51 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:40:27 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:40:31 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
My question is how can I stop mysql database.
Im getting this error
#1045 - Access denied for user 'skni'#'localhost' (using password: YES)
I found solution that to fix it I need first stop database
mysql --version
says gives the commandline tool's is version. It says nothing about whether mysqld (the 'server') is running.
This might be more informative:
mysqladmin -u root status
where you use sufficient credentials (user/password/host/port) to actually connect to the server.
#1045 - Access denied for user 'skni'#'localhost' (using password: YES)
Says that user 'skni' is not allowed to connect with the password used. This is a login problem, not a server start/stop problem. The server must be running for that message to occur.
Related
Background: I am using Ubuntu-20.04 and I needed to downgrade MySQL version from 8.0 to 5.7.
By using multiple tutorials I had not succeeded and then I installed MySQL 8.0 again but now I can not connect with MySQL 8.0.
mysql -u root -p
and got error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I think the reason was I had run these two commands:
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql*
After reinstalling mysql 8.0 i found /etc/mysql but there is no directory like /var/lib/mysql* .
Please help me to login in mysql, I have tried a lot of solutions. If you have any question, please let me know.
Some extra Details:
usman#usman-Lenovo-V310-15ISK:~$ systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2021-08-22 22:46:33 PKT; 22min ago
Process: 369742 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Aug 22 22:46:33 usman-Lenovo-V310-15ISK systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Aug 22 22:46:33 usman-Lenovo-V310-15ISK systemd[1]: Stopped MySQL Community Server.
Aug 22 22:46:33 usman-Lenovo-V310-15ISK systemd[1]: mysql.service: Start request repeated too quickly.
Aug 22 22:46:33 usman-Lenovo-V310-15ISK systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 22 22:46:33 usman-Lenovo-V310-15ISK systemd[1]: Failed to start MySQL Community Server.
It worked for me. And its perfect solution as per my problem.
Solution
Previously I performed the migration of my database from one directory to another within the server itself (/var/lib/mysql to /mnt/mysql) for lack of space.
When starting the server again, after having changed the /etc/my.cnf with the correct directory it returns me this error:
$ systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
And when I run the systemctl status command on the mysqld service it returns me:
$ systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Ter 2019-07-16 09:34:44 -03; 44s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 31923 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 31899 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 31923 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
Error: 13 (Permission Denied)
Jul 16 09:34:43 srvepl.cettro.local systemd[1]: Starting MySQL Server...
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: Failed to start MySQL Server.
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: Unit mysqld.service entered failed state.
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: mysqld.service failed.
If it is permission error, how do I free the server to accept such a directory?
Note: I am using CentOS 7
Thank you!!
If you are using Linux or Unix Server then you should check the permissions of the user to access the service. Here I can see that the user which is logged in can't access the service because of the permission problem.
Try with.
sudo systemctl start mysqld;
Or try sudo su;, enter the creds of the superuser and then try to check the service status.
Or login as superuser and then try to start the service.
Hope this may help you.
After searching i discovered that the error was the 'enforcing' permission of SELINUX.
The answer to fix this problem is:
$ sudo setenforce 0
And the server went up normally.
Are you logged in with root user?
If no, try with sudo.
Otherwise, I think is better to restart your system and try again.
If you aren't expert in linux centos don't manipulate anything.
uninstall mysql and reinstall it.
I have Percona MySQL server 5.7 running under CentOS 7 and although mysql is running without any noticeable errors, it is filling my /var/log/messages with the following every ten seconds:
Nov 15 10:07:27 server systemd: mysqld.service holdoff time over, scheduling restart.
Nov 15 10:07:27 server systemd: Starting MySQL Percona Server...
Nov 15 10:07:27 server mysqld_safe: 171115 10:07:27 mysqld_safe Adding '/usr/lib64/libjemalloc.so.1' to LD_PRELOAD for mysqld
Nov 15 10:07:27 server mysqld_safe: 171115 10:07:27 mysqld_safe Logging to '/var/lib/mysql/server.local.err'.
Nov 15 10:07:27 server mysqld_safe: 171115 10:07:27 mysqld_safe A mysqld process already exists
Nov 15 10:07:27 server systemd: mysqld.service: main process exited, code=exited, status=1/FAILURE
Nov 15 10:07:28 server systemd: Failed to start MySQL Percona Server.
Nov 15 10:07:28 server systemd: Unit mysqld.service entered failed state.
Nov 15 10:07:28 server systemd: Triggering OnFailure= dependencies of mysqld.service.
Nov 15 10:07:28 server systemd: mysqld.service failed.
Nov 15 10:07:28 server systemd: Started Service Status Monitor.
Nov 15 10:07:28 server systemd: Starting Service Status Monitor...
Even though it's stating in there that it failed to start the Percona server, it appears to be working as my website is still doing mysql queries. I know very little about mysql admin and was hoping a mysql guru could shed some light on what is happening.
The clue is here: "A mysqld process already exists". It can't start mysqld because another mysqld process is already running, and using the same port. You need to kill that process before the one you tried to start can start.
Re your comment:
Since this is CentOS 7, I assume mysql.service is being called by systemd.
In my experience, if you start mysqld "ad hoc" without using systemd, then systemd has no idea that it's running, and tries to start mysqld on its own. Systemd also cannot shut down an instance of mysqld unless it started that instance.
the mysqld process is active,ps -ef |grep mysqld ,kill -9 {}
So I've been working on a rails server with MySQL and suddenly can't access my database. When I try to log in with mysql -u root -p I get ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2). I've read most of the forums I can find and looked through all the logs trying to reset mysqld.sock. I've tried reinstalling and repackaging unsuccessfully. The weird thing is that var/run/mysqld/ doesn't even exist after reinstalling.
So I decided to just back up my databases and overhaul everything. I cleaned out both apache and mysql with apt-get remove --purge and reinstalled. All went fine, apache launched fine, and then tried to relaunch mysql with systemctl start mysql which gave a prompt to check the log which says:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Fri 2016-12-16 23:56:19 UTC; 17s ago
Process: 15690 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Control process exited, code=exited status=1
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: Failed to start MySQL Community Server.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Unit entered failed state.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Failed with result 'exit-code'.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: Stopped MySQL Community Server.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: mysql.service: Start request repeated too quickly.
Dec 16 23:56:19 ip-172-31-0-55 systemd[1]: Failed to start MySQL Community Server.
Update - I created the folder mysqld, which seems to allow sudo mysqld --initialize to run. Unfortunately this yielded the error
2016-12-17T00:16:36.298825Z 0 [ERROR] Can't change data directory owner to mysql
2016-12-17T00:16:36.299212Z 0 [ERROR] Aborting
So no party yet. Any thoughts would be hugely appreciated.
edit /etc/mysql/conf.d/mysql.cnf :
sudo nano /etc/mysql/conf.d/mysql.cnf
add this line :
socket=/var/run/mysqld/mysqld.sock
then restart mysql service :
sudo service mysql restart
I lost my mysql password and need to reset it.
I have already tried https://help.ubuntu.com/community/MysqlPasswordReset
With the following result
erik#Trantor:~$ sudo /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
erik#Trantor:~$ sudo /usr/sbin/mysqld --skip-grant-tables &
[1] 21335
erik#Trantor:~$
[1]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables
erik#Trantor:~$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
erik#Trantor:~$
I did not use the skip-networking option as that has been indicated by another post to cause it's own trouble and I'm not worried about security at the moment. Through some checking, I found that the service is failing to actually start with that option.
erik#Trantor:~$ sudo service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: inactive (dead) since Sun 2016-11-06 10:41:56 EST; 3min 45s ago
Process: 20846 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=e
Process: 20845 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
Process: 20842 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exi
Main PID: 20845 (code=exited, status=0/SUCCESS)
Nov 06 10:35:01 Trantor systemd[1]: Starting MySQL Community Server...
Nov 06 10:35:02 Trantor systemd[1]: Started MySQL Community Server.
Nov 06 10:41:55 Trantor systemd[1]: Stopping MySQL Community Server...
Nov 06 10:41:56 Trantor systemd[1]: Stopped MySQL Community Server.
lines 1-12/12 (END)
I'm not sure how to get mysql to start with the -skip-grant-tables option at this point, and without my password, I'm dead in the water.
I have tried to remove and install mysql-server again.
Anyone know how I can get it to start with the flag, or where I should look next?