start mysql server as root failed.
1.service mysqld start
Starting mysqld: [FAILED]
2.mysqld
error log:
2016-02-23T01:19:16.961857Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-23T01:19:16.963350Z 0 [Note] mysqld (mysqld 5.7.10) starting as process 20924 ...
2016-02-23T01:19:16.965669Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2016-02-23T01:19:16.965715Z 0 [ERROR] Aborting
2016-02-23T01:19:16.965737Z 0 [Note] Binlog end
2016-02-23T01:19:16.965818Z 0 [Note] mysqld: Shutdown complete
but can start mysql service as mysql user, or use mysqld_safe as root can start too. what's wrong?
/etc/init.d/msyqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
if ! /bin/kill -0 $safe_pid 2>/dev/null; then
echo "MySQL Daemon failed to start."
ret=1
break
fi
... ...
if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true
touch $lockfile
else
action $"Starting $prog: " /bin/false
fi
I found this Code Snippets in the script /etc/init.d/mysqld. but don't know why?
Add this line to /etc/my.cnf in [mysqld] section
explicit_defaults_for_timestamp = 1
Check this link
Since you can start as the mysql user, it is likely you have it currently configured to run as root.
Mysql's reference manual says:
On Linux, for installations performed using a MySQL repository, RPM packages, or Debian packages, the MySQL server mysqld should be started by the local mysql operating system user. Starting by another operating system user is not supported by the init scripts that are included as part of the installation.
/etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled
Related
I am using Ubuntu to configure Wordpress on WSL. Currently, I am trying to install MySQL as part of the LAMP Stack using the following as per this tutorial:
sudo usermod -d /var/lib/mysql/ mysql
sudo service mysql start
When I run the second command, I see "fail" in red appear (ie. mysql won't start). Here is what the Error Log looks like:
2021-09-05T08:17:59.936284Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2021-09-05T08:17:59.951837Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2021-09-05T08:17:59.962000Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
2021-09-05T08:17:59.962006Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)
2021-09-05T08:18:00.172509Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2021-09-05T08:18:00.172578Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2021-09-05T08:18:00.172626Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-09-05T08:18:00.178880Z mysqld_safe mysqld from pid file /run/mysqld/mysqld.pid ended
Edit- Here is what I get when I run the following commands:
root#DESKTOP-P44T17P:~# stat /var/lib/mysql-files
stat: cannot stat '/var/lib/mysql-files': No such file or directory
root#DESKTOP-P44T17P:~# grep user /etc/mysql/mysql.conf.d/mysqld.cnf
user = mysql
It does not look the mysql-files directory exists.
Ubuntu 20.04.2
it might be your log folder deleted for some reason. make sure there's /var/log/mysql folder. if it's don't just make new one with mysql ownership.
Ensure the directory /var/lib/mysql-files exists and MySQL should start.
You can try:
sudo mkdir /var/lib/mysql-files
I get this error when I try to start mysql with service mysql start under a Debian machine (a Docker container actually):
[FAIL] Starting MySQL database server: mysqld . . . . . failed!
I think the problem is in the Debian itself, but I'll explain the context just in case. I have the following context:
A Debian Docker container based in this image running over an Ubuntu 18.04 host.
This container was runninng properly in previous Ubuntu 16.04 and actually is still running in another computer with Ubuntu 16.04. Of course, the container has been rebuilt in new OS.
If I try sh -x /etc/init.d/mysql start to get some feedback info all I get is messages like:
+ echo -n Starting MySQL database server: mysqld
Starting MySQL database server: mysqld+ log_daemon_msg_post Starting MySQL database server mysqld
+ :
+ mysqld_status check_alive nowarn
+ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output=/usr/bin/mysqladmin: connect to server at 'localhost' failed
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'm quite stucked in this, I've been several days searching and moving in circles to no avail.
EDIT: I'll add some tries and fails I did in order to get some output or logging:
$/usr/bin/mysqld_safe -v
181010 15:30:51 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
181010 15:30:51 mysqld_safe Logging to '/var/log/mysql/error.log'.
181010 15:30:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
181010 15:30:51 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
$mysqld --print-defaults
(empty output)
$mysqld --v
(empty output)
$tail -f /var/log/mysql/error.log
(last log entry is 1 month old)
180921 10:59:40 InnoDB: highest supported file format is Barracuda.
180921 10:59:40 InnoDB: Waiting for the background threads to start
180921 10:59:41 InnoDB: 5.5.60 started; log sequence number 1595675
ERROR: 1050 Table 'plugin' already exists
180921 10:59:41 [ERROR] Aborting
180921 10:59:41 InnoDB: Starting shutdown...
180921 10:59:42 InnoDB: Shutdown completed; log sequence number 1595675
180921 10:59:42 [Note] /usr/sbin/mysqld: Shutdown complete
I have a little Problem with a MySQL Server running on a Debian Server managed by Plesk. If I try to start the MySQL Server the following message is logged at MySQL_error.log:
150518 02:54:42 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
150518 02:55:15 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150518 2:55:15 [Warning] Using unique option prefix w instead of wait_timeout is deprecated and will be removed in a future release. Please use the full name instead.
150518 2:55:15 [ERROR] /usr/sbin/mysqld: option '--wait_timeout' requires an argument
150518 2:55:15 [ERROR] Aborting
150518 02:55:15 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
But I never modified my config file and I did never set a --wait_timeout argument.
Can someone help me out?
Pay attention for this string:
"Using unique option prefix w instead of wait_timeout is deprecated"
Check that there is no "w" command argument or option in my.cnf.
I've been running MySQL Ver 14.14 Distrib 5.6.10, for osx10.6 (x86_64) for a while with no issues. I had to hard restart my laptop tonight, and a while after it started, i tried to access a dev database. I got the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
here are the commands and responses:
$ which mysql
#=> mysql: aliased to nocorrect mysql
$ unset TMPDIR
$ mysql_install_db
#=> FATAL ERROR: Could not find ./bin/my_print_defaults
$ sudo /usr/local/mysql/support-files/mysql.server start
#=> ERROR! The server quit without updating PID file (/usr/local/mysql/whoamis-MacBook-Pro.local.pid).
$ mysqld
#=> 2013-10-19 00:11:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-10-19 00:11:08 5029 [Warning] Can't create test file /usr/local/var/mysql/whoamis-MacBook-Pro.lower-test
2013-10-19 00:11:08 5029 [Warning] Can't create test file /usr/local/var/mysql/whoamis-MacBook-Pro.lower-test
mysqld: Can't change dir to '/usr/local/var/mysql/' (Errcode: 2 - No such file or directory)
2013-10-19 00:11:08 5029 [ERROR] Aborting
2013-10-19 00:11:08 5029 [Note] Binlog end
2013-10-19 00:11:08 5029 [Note] mysqld: Shutdown complete
$ usr/local/Cellar/mysql
sure enough, there was a mysql installation here, too. So there's one in /usr/local/mysql and there's one in /usr/local/Cellar/mysql, but there's not one in /usr/local/var which is where mysqld, at least, seems to be looking. It's worth noting that the system preferences tool as well as mySQL Workbench server tool doesn't successfully start the server, either. Any idea where to proceed from here?
As per this site
$ sudo mv my.cnf old_my.cnf
$ Password:
$ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
SUCCESS!
It works! However, it's good to note that this isn't perhaps the 'best' way - as Brad Quellhorst notes in the comments:
The better advice would be "Remove anything you recently added to my.cnf and remove the file as a last resort" Unless you already have a bare-defaults my.cnf, by removing it you're destroying any configuration options in favor of defaults, which among other things, are rather insecure. Binding MySQL to all open IPs and removing any caching, replication, and data information is not the solution to a typo'd configuration statement.
I'm new to the forums here but I hope to become more active as I've recently purchased a dedicated server and I'm running Fedora off of it so it's a constant learning process, I'm fairly average at BASH, but I know enough to make my way around, I'm a software developer to trade more than a network techi. Which leads me to my initial problem, I'm having an issue starting my MySQL daemon after rebooting my dedi, I have no clue why it's suddenly doing this, I'm running PHPMyAdmin from the server and also issuing certain commands through the CLI for MySQL, but after rebooting I'm getting this error everytime I try to start the instance of the daemon:
[root#ks23085 ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root#ks23085 ~]# systemctl mysqld start
Unknown operation mysqld
[root#ks23085 ~]# systemctl start mysqld
Failed to issue method call: Unit name mysqld is not valid.
[root#ks23085 ~]# systemctl start mysqld.service
[root#ks23085 ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/path/to/mysql.sock' (2)
It's completely bizarre as it was working perfectly before I rebooted it, I didn't update it or change the install, the only thing that I did do was install postfix, but I don't see why that would cause any issues with MySQL :S
I really need a hand on this one, I've tried several solutions from google with no results whatsoever. Thanks in advance guys.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Update 1:
Okay, so I found the directory that mysqld is held, it was '/usr/libexec/mysqld', I typed './mysqld start' in this directory and it specifies this output:
120729 1:49:09 [Warning] The syntax '--log-slow-queries' is deprecated and will be removed in a future release. Please use '--slow-query-log'/'--slow-query-log-file' instead.
120729 1:49:09 [Warning] The syntax '--log-slow-queries' is deprecated and will be removed in a future release. Please use '--slow-query-log'/'--slow-query-log-file' instead.
120729 1:49:09 [Warning] Can't create test file /run/mysql/ks23085.lower-test
120729 1:49:09 [Warning] Can't create test file /run/mysql/ks23085.lower-test
./mysqld: Can't change dir to '/run/mysql/' (Errcode: 2)
120729 1:49:09 [ERROR] Aborting
120729 1:49:09 [Note] ./mysqld: Shutdown complete
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Update 2:
I managed to get passed the directory issue by creating the 'mysql' directory in 'run/' with all my old databases, but now I seem to be getting an error that doesn't seem to be as easy to fix :/
Here's the output:
120729 2:15:59 [Warning] The syntax '--log-slow-queries' is deprecated and will be removed in a future release. Please use '--slow-query-log'/'--slow-query-log-file' instead.
120729 2:15:59 [Warning] The syntax '--log-slow-queries' is deprecated and will be removed in a future release. Please use '--slow-query-log'/'--slow-query-log-file' instead.
120729 2:15:59 [Warning] Can't create test file /run/mysql/ks23085.lower-test
120729 2:15:59 [Warning] Can't create test file /run/mysql/ks23085.lower-test
120729 2:15:59 [Note] Plugin 'FEDERATED' is disabled.
120729 2:15:59 [Note] Plugin 'InnoDB' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
120729 2:15:59 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120729 2:15:59 [ERROR] mysqld: unknown option '--skip-locking'
120729 2:15:59 [ERROR] Aborting
120729 2:15:59 [Note] mysqld: Shutdown complete
The official doc states that there's 2 possible reasons for this error:
You don't have permissions to access the directory /var/lib/mysql/whatever.sock because mysql is the owner of the folder
or
/path/whatever.sock doesn't exist.
Execute the following to find your socket:
mysqladmin variables | grep socket
Added to configuration file as suggested:
You can try this though [Linux specific, but what other operating
systems are there?] Go to /etc/my.cnf and change/add the lines:
[mysqld]
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
[client]
socket=/tmp/mysql.sock
2) Don't forget to check your permissions!