Mona Jalal
Mona Jalal

Reputation: 38275

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

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

Upvotes: 71

Views: 201606

Answers (15)

Professor Todd
Professor Todd

Reputation: 581

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.

Upvotes: 1

Tim
Tim

Reputation: 3198

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

Upvotes: 0

Ivan Bosnic
Ivan Bosnic

Reputation: 2006

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

Upvotes: 0

Hasitha
Hasitha

Reputation: 795

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 &

Upvotes: 2

xiaojueguan
xiaojueguan

Reputation: 1050

you might try this if you logged in with root:

mysqld --user=root

Upvotes: 52

Peter
Peter

Reputation: 17

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

mariadb run as system root user

Upvotes: 0

mondrey
mondrey

Reputation: 456

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.

Upvotes: 9

TheTechGuy
TheTechGuy

Reputation: 17384

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.

Upvotes: 0

antoni
antoni

Reputation: 5556

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.

Upvotes: 0

Leo Mago
Leo Mago

Reputation: 21

in my case (RHEL7 and MariaDB) this works.

sudo systemctl restart mariadb

Upvotes: 1

Saurabh Chandra Patel
Saurabh Chandra Patel

Reputation: 13644

Try this for Amazon Linux AMI or for centOS

sudo service mysqld restart

Upvotes: 7

Andy Stutzman
Andy Stutzman

Reputation: 11

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

com.oracle.oss.mysql.mysqld.plist.

Upvotes: 1

Mise
Mise

Reputation: 3567

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

Upvotes: 96

Donal
Donal

Reputation: 32773

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

sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

Upvotes: 2

MrTux
MrTux

Reputation: 34032

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

Upvotes: 13

Related Questions