This question already has answers here:
How to give apache permission to write to home directory?
(5 answers)
Closed 2 years ago.
I get the Permission denied error every time I try to write a file to (/var/lib/mysql-files) directory with http, but if I restart apache and/or MySQL I can write to that directory with no errors, but only one time, so if I try to write a second file I will get that error, and I have to restart apache again and so on.
This is the ownership and the permissions that i gave that directory:
groupadd mysql_apache
usermod -a -G mysql_apache mysql
usermod -a -G mysql_apache apache
chown -R :mysql_apache /var/lib/mysql-files
chmod -R 770 /var/lib/mysql-files
I want to give the rights to read; write; execute on this dir (/var/lib/mysql-files) only to MySQL and apache, What did I do wrong here?
PS: This is on CentOs 8.
We moved to Ubuntu 20.04 since CentOs 8 EOL changed to 2021, and I didn't have this problem in Ubuntu.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Configuring mysql-server-5.7 (5.7.11-0ubuntu6) …
insserv: warning: current start runlevel(s) (empty) of script `mysql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `mysql' overrides LSB defaults (0 1 6).
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error with
mysql-server-5.7 (--configure):
apt-get remove return the same result.
This error come in with upgrade from 15.10 to 16.04
It was exactly same for me: runlevel warnings and mysql_upgrade error.
I guess it was because I disabled mysql service, enabling it fixes the problem:
sudo systemctl enable mysql
I've just encountered this problem, there's a bug report that is quite similar here: https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1584287
In my case I had the mysql.service set to disabled and the mysql_upgrade script seemed incapable of starting the server in this case. I enabled the service (didn't need to start it) and re-ran the upgrade. After that worked I stopped the service and disabled it again.
I'm not sure what else might cause this, but if someone encounters this with the service disabled, just enable it for the upgrade.
Manualy remove all file of MySQL server
Seems mysql-server is now replaced with mariadb
Installing maridb-server fixed the issue.
sudo apt-get install mariadb-server
Note:- You won't get your databases. Reset mysql password using command mysql_secure_installation
In my case I could solve the problem by changing apparmor (on kubuntu 16.04 using plasma).
I took a look at journalctl -xe as suggested by the installation error message:
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
In there I found apparmor DENIED messages:
AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/home/system/var/log/mysql/error.log" pid=32610 comm="mysqld" request
In deed, the base directory /home/system/... exists, but access is not allowed by /etc/apparmor.d/usr.sbin.mysqld.
So adding the following lines to /etc/apparmor.d/local/usr.sbin.mysqld solved my problem:
# For more details, please see /etc/apparmor.d/local/README.
# Allow log file access
/home/system/var/log/mysql.err rw,
/home/system/var/log/mysql.log rw,
/home/system/var/log/mysql/ r,
/home/system/var/log/mysql/** rw,
Don't forget to restart apparmor, and restart mysql installation (e.g. apt-get install --reinstall mysql-common mysql-server or whatever is your way to install it.)
I don't know at all why (and since when) the directory /home/system exists and why mysql points in there. But some day a hopefully figure out ... ;)
Below worked for me, found solution - here
sudo update-alternatives --remove my.cnf /etc/mysql/my.cnf.migrated
sudo service mysql start
I found the solution here
Remove all of mysql's files:
rm -r /var/lib/mysql*
Install mysql self database:
mysql_install_db -u mysql
(might not work for newer systems, but don't worry)
Enable the service for systemd: systemctl unmask mysql.service
Then start the mysql service service mysql start
Ok, I've searched all over and have spent quite a bit of my time installing, uninstalling, trying various option but without success.
I'm on Mac OS X Lion (10.7.3) and am trying to setup a Python, MySQL.
I successfully installed Python and MySQL via HomeBrew.
Python works great.
After MySQL Installation, I followed the first 2 steps - unset and the mysql_install_db commands.
Now, when I try to start mysql "mysql.server start", I get the following error
ERROR! The server quit without updating PID file (/usr/local/var/mysql/Brajeshwar.local.pid).
Brajeshwar is my username on my machine.
I found that it was a permissions issue with the mysql folder.
chmod -R 777 /usr/local/var/mysql/
solved it for me.
EDIT 2012/09/18:
As pointed out by Kane, make sure the mysql database is properly set up before doing anything else. See “PID error on mysql.server start?” for more info.
Original answer kept for history's sake:
It most likely is a permissions issue. Check /usr/local/var/mysql/*.err. Mine said:
120314 16:30:14 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120314 16:30:14 mysqld_safe mysqld from pid file /usr/local/var/mysql/janmoesen.local.pid ended
I also had to do this:
sudo chown _mysql /usr/local/var/mysql/*
I ended up with completely reinstalling of mysql, and it finally worked out.
WARNING This will remove all of your databases, so make sure to save dumps first.
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql
brew install mysql
mysqld --initialize --explicit_defaults_for_timestamp
mysql.server start # no sudo!
I had this issue on mac 10.10.5 Yosemite
What I did to solve this
cd /usr/local/var/mysql
sudo rm *.err && sudo rm *.pid
sudo reboot
sudo mysql.server start
I had the same issue on OS X El Capitan, here's the terminal command sequence that fixed it for me.
Delete error files (you'll have to change the path depending on your setup)
sudo rm /usr/local/mysql/data/*.err
Find the info for the mysql process that's still running and kill it:
ps -A | grep -m1 mysql | awk '{print $1}' | sudo xargs kill -9
Now restart MySQL:
/usr/local/mysql/support-files/mysql.server start
November, 2014: If you're getting this error on MySQL 5.6.x on Mac OS X Mavericks or Yosemite and want to use MySQL with PHP locally (/tmp/mysql.sock is where PHP PDO expects to find the sock file), here is what fixed it for me:
1) Uncomment the default homebrew config file lines and edit as below
$ sudo vi /usr/local/Cellar/mysql/5.6.21/my.cnf
...
basedir = /usr/local/Cellar/mysql/5.6.21
datadir = /usr/local/var/mysql
port = 3306
server_id = <UNIQUE_NUMBER_HERE_OR_LEAVE_COMMENTED_OUT>
socket = /tmp/mysql.sock
pid-file = /usr/local/var/mysql/[BOXNAME].local.pid
....
BOXNAME is what you have in your System Prefs -> Network as the unique id for your computer on the network.
2) Set permissions on all the files in the mysql datadir. These were all owned by [my_username]. MySQL is very picky about this and refuses to create the pid file unless it (the user _mysql) owns the directory.
$ sudo chown -R _mysql:mysql /usr/local/var/mysql
3) Start MySQL using the bash helper/wrapper script:
$ sudo mysql.server start
Starting MySQL
. SUCCESS!
Hope that helps. If the above doesn't work for you, try to run the mysqld_safe binary manually in the Cellar/mysql/VERSION_/bin/ directory and check what the settings are (if it runs)
sudo /usr/local/Cellar/mysql/5.6.12/bin/mysqld_safe &
If that runs, you can
ps aux | grep mysql
and see something like
[username] 6881 0.0 2.7 3081392 454836 ?? S 8:52AM 0:00.54 /usr/local/Cellar/mysql/5.6.21/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.21 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.21/lib/plugin --verbose --log-error=/usr/local/var/mysql/BOXNAME.local.err --pid-file=/usr/local/var/mysql/BOXNAME.local.pid
I'm not sure why that worked for me but it shows you where I got the my.cnf config file options from. You can also use the command line options to try to troubleshoot when starting mysqld manually.
If you do run manage to run MySQL server using mysqld_safe, you may have to do this to shut it down before trying the mysql.server bash helper. Resist the urge to kill -9 [PID] because you can corrupt your data.
mysqladmin -uroot shutdown
Good luck!
This worked for me:
sudo chmod -R 777 /usr/local/var/mysql/
sudo /usr/local/mysql/support-files/mysql.server start
This worked for me on 10.12.2 :
$ rm /usr/local/var/mysql/*.err
then
$ brew services restart mysql
If I remember correctly it is a permissions issue. Try to 'touch' and 'chmod' the pid file or the folder the file is held in.
My issue was that I started server as sudo once and then tried to restart as a local user.
Here mysql was not able to write to '.err' file owned by root.
I had to remove that file and restart the server:
sudo rm /usr/local/var/mysql/*.err
mysql.server start
Try this (OSX)
Step 1:
ps -aux | grep mysql
Then kill the 4 digits PID number
Step 2: kill 1965
Step 3: mysql.server start
Or having hard time to locate those PID numbers, try this below
Step 1 again: ps -aux | grep mysql
Step 2 again: killall
Step 3 again: mysql.server start
I’ve got a similar problem with MySQL on a Mac (Mac Os X Could not startup MySQL Server. Reason: 255 and also “ERROR! The server quit without updating PID file”). After a long trial and error process, finally in order to restore the file permissions, I’ve just do that:
launch the Disk Utilities.app
choose my drive on the left panel
click on the “Repair disk permissions” button
This did the trick for me. Hoping this can help someone else.
Find usr/local/var/mysql/your_computer_name.local.err file and understand the more information about error
Location : /usr/local/var/mysql/your_computer_name.local.err
It's probably problem with permissions
Find if mysql is running and kill it
ps -ef | grep mysql
kill -9 PID
where PID is second column value
2. check ownership of mysql
ls -laF /usr/local/var/mysql/
if it is owned by root, change it mysql or your user name
sudo chown -R mysql /usr/local/var/mysql/
For me it worked with:
unset TMPDIR
mysql_install_db --user=`whoami` --basedir="$(brew --prefix mariadb)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
What worked for me was:
Go to your mysql installation directory
sudo chmod -R 777 data
Then go back one directory
cd support-files/
sudo ./mysql.server start
After that the server started running.
But the problem with this method is that I have to repeat this every time I want to start the mysql now. Don't know why it started behaving like this suddenly.
I had this problem on Linux, but the cause is relevant to any mysql installation. In my case, the server was crashing before startup was complete and the pid file updated. The error messages were seen when starting up mysqld directly instead of via "service mysql start".
In my case, the cause was the partition where the log files were located being full. Removing log files permitted mysql to start again. To test for this issue, go to the location of your mysql activity logs, and do df ..
If you have upgraded your mysql installation to 8.x, check if your previous version is supported for upgradation.
If not, mysql will not work! Uninstall your mysql along with all configuration files in /usr/local/var/mysql (remove the whole folder). Reinstall mysql.
NOTE: reinstalling might lead to loss of data.
Please check the log , you will get more detailed information .
Use the below command to tail the error log
tail -100 /usr/local/var/mysql/<user_name>.local.err
For me , one of the directory is missing , once created the server has started .
The key takeaway is to check the .err file, by default on Mac OSX it's in /usr/local/var/mysql.
That log filed revealed to me that I had to delete the following files:
ibdata1
ib_logfile0
ib_logfile1
Running MySQL with mysql.start worked successfully after that. Note that deleting those files will likely causes data loss.
sudo chmod -R 777 /usr/local/var/mysql/
works for me.
I had the same issue:
But the situation was, every time i try to enter:
/usr/local/mysql/support-files/mysql.server start
a file named localhost.pid is created instead of iMax0.local.pid which was stated in the error:
ERROR! The server quit without updating PID file (/usr/local/mysql/data/iMax0.local.pid).
Solution that works for me was copying localhost.pid and renaming it to iMax0.local.pid.
My solution on OSX El Capitan was:
sudo chmod ugo+w /tmp
It was broken suddenly.
The error was:
ERROR! The server quit without updating PID file
and the log showed:
Can't start server : Bind on unix socket: Permission denied
It might also be helpful to note, that under OSX there is no my.cnf file by default and not needed by default, which I did not know. Good luck!
$ sudo mysql.server restart
It works for me.
I had the similar issue. But the following commands saved me.
cd /usr/local/Cellar
sudo chown _mysql mysql
This is file permission problem.
Check disk permissions and repair.
Osx => Cmd+Space => Disk Utilty => Verify Disk Permissions.
Verify completed after Repair Disk Permissions.
mysql.server start command is worked succesfuly.
None of the answers worked for me. However, I simply did sudo mysql.server start and it worked nicely.
Also, for me, it did NOT show permissions issue in *.err file.
all solutions above doesn't work for me.
but they give me some clues to fix this error.
mysql.server start ----error The server quit without updating PID file
I installed mysql#5.7 on my macbook mojave with homebrew
brew install mysql#5.7
mysql error log located in /usr/local/var/mysql/IU.lan.err,there is one line in it:
Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
after trying many posts in goole search engine,I turned to baidu
https://blog.csdn.net/xhool/article/details/52398042
inspired by this post,I found the solution:
rm /usr/local/var/mysql/*
mysqld --initialize
a random password for root user will be shown in bash.
but the command mysql -uroot -p[theRandomPassword] cant work.so I have to reset password.
create a init file with contents like this
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
place it in any directory easy to find,such as Desktop
mysqld --init-file=[YourInitFile] &
many logs printed on your screen.
mysql -uroot -pMyNewPass
enjoy your high-version mysql!
Happened to me because I was actually switching from MariaDB to Mysql.
Switching back to MariaDB solved this.
I'm guessing the existing database wasn't compatible.
Solved this using sudo chown -R _mysql:_mysql /usr/local/var/mysql
Thanks to Matteo Alessani
This error may be actually being show because mysql is already started. Try to see the current status by:
mysql.server status
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have been attempting to install MySQL 5.1.59 from source for the last couple of days on a Debian server. Every time I run the build process everything appears to go completely smooth(including make test). After completing post install steps I try running the client and get a segmentation fault as seen below. I understand that I could easily install this using apt, but I am determined to build MySQL from source at least once. Any ideas or helpful hints would be greatly appreciated. Thanks ahead of time!
debiantesting-01:/usr/local/mysql# bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.59-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Segmentation fault
Here is a complete list of the commands I ran in order.
groupadd mysql
useradd -g mysql mysql
tar -xvf mysql*
cd mysql*
ls
./configure --prefix=/usr/local/mysql --with-extra-charsets=all
make
make test
make install
cd /usr/local/mysql
ls
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
cp /usr/local/src/mysql*/support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/share/mysql/mysql.server start --user=mysql
/usr/local/mysql/bin/mysql_secure_installation
bin/mysql -u root -p
I have tried starting the server with and without the --user flag and it doesn't change the outcome. Also I have tried the command that it says "cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &" and it stays in the foreground and displays:
[1] 31150
debiantesting-01:/usr/local/mysql# 111115 09:37:30 mysqld_safe Logging to '/usr/local/mysql/var/debiantesting-01.err'.
111115 09:37:30 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
After running that the log shows:
111115 10:30:42 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
111115 10:30:42 [Note] Event Scheduler: Loaded 0 events
111115 10:30:42 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.
Version: '5.1.59-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution
If you need anymore information please feel free to ask and thank you very much for your time!
-Josh
After taking the advice of Sjoerd I used gdb to run a backtrace and was able to find a bug report that matched my situation. http://bugs.mysql.com/bug.php?id=58497 is the link. Basically you have to modify the term.c file's lines 904: comment it out and 914: set area equal to NULL.
Example
904: //char buf[TC_BUFSIZE];
914: area = NULL;
Once you have made these changes you should be able to rebuild MySQL.
The file should be located at (MySQL Source Location)/cmd-line-utils/libedit/term.c
otherwise you can use a find / -name "term.c" to find it.
Hope this helps!
-Josh