Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root
Asked Answered
E

15

68

I am not sure how to fix this:

dyn-72-33-214-45:python mona$ sudo /usr/local/mysql/bin/mysqld stop
2014-09-06 09:49:04 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-06 09:49:04 22992 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.6.15-osx10.7-x86_64/data/ is case insensitive
2014-09-06 09:49:04 22992 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2014-09-06 09:49:04 22992 [ERROR] Aborting

2014-09-06 09:49:04 22992 [Note] Binlog end
2014-09-06 09:49:04 22992 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
Emlyn answered 6/9, 2014 at 13:50 Comment(9)
I suppose you wanted to execute sudo /etc/init.d/mysql stop (an initscript and not the mysqld binary).Balboa
/usr/local/mysql/bin/mysqladmin -u root shutdownArlyn
@Arlyn /usr/local/mysql/bin/mysqladmin -u root shutdown /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!Emlyn
What do you want to do? Do you want to start or stop it? - Are you sure mysqld is really running?Balboa
Is mysqld running? Check it with this: ps -ef | grep mysqldArlyn
@Balboa I want to stop itEmlyn
@Arlyn ps -ef | grep mysqld 501 66888 1 0 18Aug14 ?? 0:00.03 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log 501 67004 66888 0 18Aug14 ?? 0:30.92 /Applications/MAMP/Library/bin/mysqld --basedir=/Applications/MAMP/Library --datadir=/Applications/MAMP/db/mysql --plugin-Emlyn
@MonaJalal Can you add that output to your question? OSX may be using a daemon to launch mysql. I have posted an answer that will help you unload it.Arlyn
sudo service mysql statusFilip
L
96

I'm using OS X (Yosemite) and this error happened to me when I upgraded from Mavericks to Yosemite. It was solved by using this command

sudo /usr/local/mysql/support-files/mysql.server start
Lietuva answered 19/10, 2014 at 12:28 Comment(2)
While this solution did work to get MySQL running, it doesn't seem like the most correct solution. The MySQL documentation says the files in this directory are for building the server, not for general usage. dev.mysql.com/doc/internals/en/support-files-directory.htmlHateful
Following this threw a ERROR! The server quit without updating PID file error. I looked into /usr/local/mysql/data/*.err file (the name is as per your username) & it pointed that mysqld aborted as it is unable to connect to /tmp/mysql.sock.lock . I had that file already created (as a different user I guess) & I removed it manually. The command now works.Pavla
P
49

you might try this if you logged in with root:

mysqld --user=root
Pitchstone answered 6/3, 2020 at 7:41 Comment(0)
B
13

The MySQL daemon should not be executed as the system user root which (normally) do not has any restrictions.

According to your cli, I suppose you wanted to execute the initscript instead:

sudo /etc/init.d/mysql stop

Another way would be to use the mysqladmin tool (note, root is the MySQL root user here, not the system root user):

/usr/local/mysql/bin/mysqladmin --port=8889 -u root shutdown
Balboa answered 6/9, 2014 at 13:54 Comment(2)
I am using osx ! sudo: /etc/init.d/mysql: command not foundEmlyn
As you're not using the default port, you have to add your special port to the second command or the socket-path: --socket=/Applications/MAMP/tmp/mysql/mysql.sockBalboa
R
8

How i resolved this was following the 4th point in this url: https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html

  1. Edit my.cnf
  2. Add user = root under under [mysqld] group of the file

If this doesn't work then make sure you have changed the password from default.

Refine answered 20/12, 2019 at 8:33 Comment(0)
J
7

Try this for Amazon Linux AMI or for centOS

sudo service mysqld restart
Jacquelynnjacquenetta answered 31/1, 2018 at 16:43 Comment(1)
IIR systemctl is generally preferred in CentOS / RHELFooter
A
2

osx could be using launchctl to launch mysql. Try this:

sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
Arlyn answered 6/9, 2014 at 14:18 Comment(0)
W
2

I also had the same problem and able to resolve after using below command

/root/mysql-sandboxes/3320/bin/mysqld --defaults-file=/root/mysql-sandboxes/3320/my.cnf  --user=root &
Weaverbird answered 30/4, 2020 at 1:39 Comment(0)
L
1

Donal had the right solution for me. However, the updated plist name for 2017 is

com.oracle.oss.mysql.mysqld.plist.
Laine answered 28/11, 2017 at 16:33 Comment(0)
A
1

in my case (RHEL7 and MariaDB) this works.

sudo systemctl restart mariadb
Accentual answered 28/2, 2018 at 18:52 Comment(0)
K
0

On top of @mise's answer, After I installed MacOS Mojave, I also had to change files ownership on all my MAMP directory and contents).

From the Finder, I went in Application/MAMP, showed files info (cmd + i) and in permissions section added myself with read & write perms, then from the little gear applied to all the children.

Kwasi answered 28/1, 2019 at 1:11 Comment(0)
F
0

The correct answer that worked for me on CentOS is

/etc/init.d/mysql restart

which is an init script and not /etc/init.d/mysqld restart, which is binary

The is in fact comment of @MrTux on the question which worked for me. It took quite a bit of my time hence posting it as answer.

Florilegium answered 23/2, 2019 at 12:19 Comment(0)
M
0

to run mysqld as root user from command line you need to add the switch/options --user=root

mariadb run as system root user

Monohydric answered 23/12, 2019 at 23:12 Comment(0)
T
0

I had this issue while running MySQL on Minikube (Ubuntu box) and I solved it with:

sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
Turkmen answered 7/6, 2020 at 17:20 Comment(0)
B
0

Very weird, but I got this error when I made a typo in the my.cnf file.
So it had nothing to do with the user directive not defined or not running as root-user.

My mistake was:

bind=192.168.1.2

instead of

bind-address=192.168.1.2
Bolduc answered 17/12, 2020 at 15:0 Comment(0)
I
0

If you started your server as root, you'll need to shut it down as root

sudo brew services stop [email protected]

Here's how to see if the service is running

sudo launchctl list | grep -i mysql

For me, I had to stop the service, then run brew uninstall [email protected], then rm -rf /opt/homebrew/var/mysql, and then reinstall and restart mysql.

Imogeneimojean answered 19/7, 2023 at 23:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.