I am a beginner to programming world: Been googling and trying many things for two days... but no solution.
Installed cptserver for LAMP, for virtual machine (Git, vagrant, puppet): https://github.com/pigeontech/cptserver
When I try to start Mysql, I get the following errors:
vagrant#localhost:~$ /usr/bin/mysqld_safe &
[1] 3404 vagrant#localhost:~$ 160311 01:02:50 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.
160311 01:02:50 mysqld_safe Logging to '/var/log/mysql/error.log'.
touch: cannot touch ‘/var/log/mysql/error.log’: Permission denied
chmod: cannot access ‘/var/log/mysql/error.log’: Permission denied
cat: /var/run/mysqld/mysqld.pid: Permission denied
rm: cannot remove ‘/var/run/mysqld/mysqld.pid’: Permission denied
160311 01:02:50 mysqld_safe Fatal error: Can't remove the pid file:
/var/run/mysqld/mysqld.pid
Please remove it manually and start /usr/bin/mysqld_safe again; mysqld
daemon not started
/usr/bin/mysqld_safe: 126: /usr/bin/mysqld_safe: cannot create
/var/log/mysql/error.log: Permission denied
vagrant#localhost:~$ [1]+ Exit 1
/usr/bin/mysqld_safe
Can some one show me a solution in simple way?
At last, I could resolve it by the following steps:
$ sudo mysql_install_db
/usr/bin/mysql_secure_installation
$ sudo /usr/bin/mysqld_safe &
Opened a new window (Alt + F2) and brought the cursor to vagrant#localhost:~$
Then, opened MySQL by:
$ sudo /usr/bin/mysql -u root -p mysql
Related
I notice that a mysqld process is running on port 3306:
$ sudo lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 63026 _mysql 19u IPv6 0x67fbb37dac8af9c7 0t0 TCP *:mysql (LISTEN)
I would like to stop this process. However, if I try mysql.server stop, I get the following error:
$ mysql.server stop
ERROR! MySQL server PID file could not be found!
I'm on MacOS, by the way. Using sudo, I'm able to find a .pid file:
$ pwd
/usr/local/mysql
$ sudo find . -name '*pid'
./data/mysqld.local.pid
However, I'm not sure whether it's the one expected by the mysql.server stop command.
The problem I'm ultimately trying to solve is that when I try the mysql command, I get the following error:
$ mysql
ERROR 1045 (28000): Access denied for user 'kurtpeek'#'localhost' (using password: NO)
I'm trying to follow the password reset instructions at https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html, but I can't seem to get past the first step, which is to stop the MySQL server. Any help would be much appreciated.
I found a high-level explanation of this problem at https://apple.stackexchange.com/questions/255671/error-mysql-server-pid-file-could-not-be-found. The server has to be stopped using the MySQL Preferences Pane:
Now the sudo lsof -i :3306 command doesn't show any processes running.
I'm having trouble connecting to MySQL with from Ubuntu 16.04:
mysql -u root -p
which returns the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
When I try starting the server with:
sudo service mysql start
mysqld_safe --skip-grant-tables &
the output is:
# 2017-01-26T20:11:45.329764Z mysqld_safe Logging to syslog.
2017-01-26T20:11:45.333031Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:11:45.336684Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:11:45.358956Z mysqld_safe A mysqld process already exists
If I kill the process with:
ps aux | grep "msyql"
kill -9 pid
and then run:
mysqld_safe --skip-grant-tables &
I get:
2017-01-26T20:10:07.979813Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:10:07.984114Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:10:07.987546Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
It's an endless loop. So then what if I reinstalled from scratch?
First remove MySQL:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
Then reinstall:
sudo apt-get update
sudo apt-get install mysql-server
sudo mysql_install_db // (deprecated command)
sudo /usr/bin/mysql_secure_installation
As far as here:
sudo /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
Error: Access denied for user 'root'#'localhost' (using password: YES)
or:
mysqladmin -u root password [newpass]
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
Then it falls down.
I've tried following all of the answers here - ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Sometimes a temporary password is stored according to others, but it's not stored in /var/log/mysqld.log as suggested
Anybody able to help?
If you are running mysqld_safe --skip-grant-tables & and getting the following error:
2017-01-26T20:10:07.984114Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:10:07.987546Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists
It might be because MySQL 5.7 and above create the /var/run/mysqld directory dynamically while running. When you stop it with service mysql stop to run mysqld_safe --skip-grant-tables , it's not available.
You can create it manually before running mysqld_safe:
service mysql stop
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
mysqld_safe --skip-grant-tables &
Then you can change the root password or whatever you were trying to do.
How you read this web page and tried the method(s) described there?
Resetting the Root Password: Unix and Unix-Like Systems
I have accidentally deleted all mysql users and hence not able to access any database.
i am using http://www.kevssite.com/2011/07/02/deleted-rootlocalhost-account-in-mysql/ link to recreate root user account again.
but the problem is that whenever I issue command sudo mysqld_safe --skip-grant-tables & my scripts hangs forever. because of this i am not able to follow next steps mentioned in the above given link.
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.
151130 18:17:51 mysqld_safe Logging to '/var/log/mysql/error.log'.
151130 18:17:51 mysqld_safe A mysqld process already exists
Make sure to kill mysqld first before running mysqld_safe:
killall mysqld mysqld_safe
# give it 10 seconds or so to shut down cleanly
ps aux | grep mysqld
# if you still see mysqld, more violent action might be needed,
# but it might
# corrupt your data. But if it a test or empty install, no problem
killall -9 mysqld mysqld_safe
# now mysqld_safe should start
And you should also remove either syslog or log-error from my.cnf to address the complaint in the first error message from mysqld_safe.
i have reinstalled mysql server in cent OS RHEL5.5 , Im getting the following error
touch: cannot touch `/var/log/mysqld.log': Permission denied
chown: changing ownership of `/var/log/mysqld.log': Operation not permitted
chmod: changing permissions of `/var/log/mysqld.log': Operation not permitted
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
I have checked the permissions for log files , its having correct permissions as mysql user
-rw-r----- 1 mysql mysql 5931 Mar 9 04:36 mysqld.log
Please let me know the issue on this and how to solve it.
Thanks
Ok. I have solved the issue,
$ /usr/libexec/mysqld --skip-grant &
[1] 5388
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
150312 10:03:28 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.95' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
$ rm -rf /var/lib/mysql/ib_logfile0
$ rm -rf /var/lib/mysql/ib_logfile1
$ ls -l /var/lib/mysql
i have removed the log files and restart the mysql server.
Thanks
The workaround is:
$ sudo touch /var/log/mysqld.log
$ sudo chown mysql:mysql /var/log/mysqld.log
$ sudo chcon system_u:object_r:mysqld_log_t:s0 /var/log/mysqld.log
In my case, this happened to me after downgrading an AWS EC2 instance. The error was as follows:
$ service mysqld start
touch: cannot touch ‘/var/log/mysqld.log’: Permission denied
chown: changing ownership of ‘/var/log/mysqld.log’: Operation not permitted
chmod: changing permissions of ‘/var/log/mysqld.log’: Operation not permitted
chown: changing ownership of ‘/var/lib/mysql’: Operation not permitted
chmod: changing permissions of ‘/var/lib/mysql’: Operation not permitted
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
Turns out the issue was the new downgraded VM didn't have enough memory as MySQL was trying to reserve.
Updating the value reserved for InnoDB on etc/my.cnf solved the issue:
innodb_buffer_pool_size=4G
No other changes on the file system permissions were needed.
In my case, there is problem with ubuntu apparmor.
Solution:
Edit mysqld profiles (usually in /etc/apparmor.d/usr.sbin.mysqld) and make sure you have:
/var/log/mysqld.log rw,
systemctl reload apparmor
touch /var/log/mysqld.log
chown mysql:mysql /var/log/mysqld.log
chmod 0644 /var/log/mysqld.log
systemctl restart mysql
I am trying to install MySQL on ubuntu 14.04 from the deb packages. I am having trouble starting the mysql server, it looks like a permissions problem. I followed the steps outlined here. Downloaded/untarred/installed deb tar bundle.
sudo apt-get install libaio1
tar -xvf mysql-server_5.7.4-m14-2ubuntu14.04_amd64.deb-bundle.tar
md5sum mysql-server_5.7.4-m14-2ubuntu14.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-server_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient18_5.7.4-m14-2ubuntu14.04_amd64.deb
Here is where the files are installed on my system:
All configuration files (like my.cnf) are under /etc.
All binaries, libraries, headers, etc., are under /usr.
The data directory is under /var.
Following these instructions
I create a mysql group and user:
groupadd mysql
useradd -r -g mysql mysql
I change the ownership of mysql scripts to mysql (as per the instructions, but doubt this is necesssary)
cd /usr/bin
sudo chown mysql mysq*
sudo chgrp mysql mysq*
I run mysql_install_db to set up grant tables
sudo mysql_install_db --user=mysql
I switch back to root the ownership and group of mysql scripts.
cd /usr/bin
sudo chown root mysq*
sudo chgrp root mysq*
I change the ownership and group of /data to mysql. Location is /var/lib/mysql
cd /var/lib
ls -l mysql
total 122896
-rw-rw-rw- 1 mysql mysql 56 Jul 26 10:17 auto.cnf
-rw-rw-rw- 1 mysql mysql 12582912 Jul 26 10:17 ibdata1
-rw-rw-rw- 1 mysql mysql 50331648 Jul 26 10:17 ib_logfile0
-rw-rw-rw- 1 mysql mysql 50331648 Jul 24 17:36 ib_logfile1
-rw-rw---- 1 mysql mysql 12582912 Jul 26 10:17 ibtmp1
drwxrwxrw- 2 mysql mysql 4096 Jul 24 17:36 mysql
drwxrw-rw- 2 mysql mysql 4096 Jul 24 17:36 performance_schema
drwxrw-rw- 2 mysql mysql 4096 Jul 24 17:36 test
Now, when I try to start the mysql server, I get permission errors:
mysqld_safe --user=mysql &
[4] 5680
/var/lib$ 140727 00:42:17 mysqld_safe Logging to '/var/log/mysql/error.log'.
cat: /var/run/mysqld/mysqld.pid: Permission denied
rm: cannot remove ‘/var/run/mysqld/mysqld.pid’: Permission denied
140727 00:42:17 mysqld_safe Fatal error: Can't remove the pid file:
/var/run/mysqld/mysqld.pid
Please remove it manually and start /usr/bin/mysqld_safe again;
mysqld daemon not started
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
Similarly, if I try to start the server as root:
mysqld_safe -p -u root
140727 00:54:08 mysqld_safe Logging to '/var/log/mysql/error.log'.
140727 00:54:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
/usr/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
140727 00:54:08 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
Apparently there are many places where I should be changing permissions, which does not look like the way to go. Three questions:
Is there some evident point where I went wrong, or should I just uninstall and apt-get everything?
Should I have owner mysql and group mysql for all files that the server needs to update?
Is there a comprehensive list of locations where these files are?
You cannot create /var/log/mysql/error.log. First create the directory if it doesn't exist
sudo mkdir -p /var/log/mysql
Next, change ownership
sudo chown -R mysql /var/log/mysql
and then try again to start the server as root:
sudo mysqld_safe --user=mysql &
If the server does not start paste here the error messages