Debian Plesk Server: MySQL doesn't start - mysql

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.

Related

Server quit without running PID file when trying to start MySQL server?

So I created my .bash_profile, opened it in a text editor and added:
export PATH=$PATH:/usr/local/mysql/bin
and then I saved it. Next, I tried running
sudo /usr/local/mysql/support-files/mysql.server start
was told to enter my password (so I did), and then terminal said
Starting MySQL
and then it kept printing dots until it said:
ERROR! The server quit without updating PID file (/usr/local/mysql/data/Nicks-MacBook-Pro.local.pid).
The error logs look like:
2021-01-25T20:50:49.707062Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.23) starting as process 15092
2021-01-25T20:50:49.710232Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2021-01-25T20:50:49.834599Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-01-25T20:50:49.943719Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-01-25T20:50:50.037810Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2021-01-25T20:50:50.125494Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-01-25T20:50:50.126128Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-01-25T20:50:50.151069Z 0 [System] [MY-010931] [Server] /usr/local/mysql/bin/mysqld: ready for connections. Version: '8.0.23' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server - GPL.
~
~
~
~
~
(END)
How do I fix this?
You should try to restart MySQL service after performing each step to check if the error is solved.
But first, take a full backup of MySQL data directory /var/lib/mysql/ before you make any changes to MySQL service.
Connect to your server via SSH as root user and restart MySQL manually. Sometimes restarting the MySQL server may fix this issue. You can use either of the following command to restart MySQL server.
/etc/init.d/mysql restart
or
service mysql restart
You need to check whether the MySQL service is already running. If MySQL service is already running, you will have to kill them and start again. Use the following command to check if there is a MySQL service running already.
ps -aux | grep -i mysql
If MySQL service is already running, you will get list of MySQL processes with PIDs. The PID is the process ID of the MySQL processes. You will have to kill those processes.
kill -9 PID
PID – Process ID of the MySQL process.
Check the ownership of MySQL data directory /var/lib/mysql/. Use the following command to check ownership of MySQL service
ll -aF /var/lib/mysql/
If it’s owner is root, you should change the ownership to MySQL or your user by using the following command.
chown -R mysql /var/lib/mysql/
Take a backup of mysql.sock file and remove it. To achieve this, use the following commands:
cp /var/lib/mysql.sock /var/lib/mysql.sock_bkp
rm -rf /var/lib/mysql.sock
Remove MySQL configuration file /etc/my.cnf or just back it up for now and restart:
mv /etc/my.cnf /etc/my.cnf.bak
Remove the log file named ib_logfile in the MySQL data directory /var/lib/mysql/ or just back it up now and restart the MySQL service. Sometimes MySQL service fails to start when it faces difficulty in updating the log files. The log files will be created automatically once you restart the MySQL service. Use the following command to remove the log files and back it up.
Change the present working directory to MySQL data directory.
cd /var/lib/mysql
Backup and remove the log files by renaming them.
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
Move the backups to a temporary location.
mv /var/lib/mysql/ib_logfile* /tmp/folder/
Find the log files with suffix “.err” in the MySQL data directory /var/lib/mysql/. These files contain the actual error message. You can use any editor or command like cat, less to read the error message from the log files.
cat /var/lib/mysql/yourservername.err
In many cases, MySQL will run soon after removing this error files.
rm -rf /var/lib/mysql/yourservername.err

Failed to find valid data directory. MySQL generic binary installion

Im going to install mysql to linux server. But I dont have root access to that server. So I created two folders called mysql and mysqldata. mysql folder holds binary files. mysqldata folder holds data and the logs.
my.cnf
[mysqld]
user = mysql
port = 3306
bind-address = localhost
basedir = /home/nwn/mysql/mysql-8.0
socket = /home/nwn/mysqldata/instA/socket/mysql.sock
datadir = /home/nwn/mysqldata/instA/data
tmpdir = /home/nwn/mysqldata/instA/tmp
secure_file_priv = /home/nwn/mysqldata/instA/mysql-files
max_connections = 150
# Logging
log-bin = /home/nwn/mysqldata/instA/logs/instA-binlog
log-error = /home/nwn/mysqldata/instA/logs/instA-errorlog.err
slow_query_log = 1
slow_query_log_file = /home/nwn/mysqldata/instA/logs/instA-slowquery.log
long_query_time = 0.5
# InnoDB
innodb_data_home_dir = /home/nwn/mysqldata/instA/innodb/data
innodb_data_file_path = ibdata1:50M;ibdata2:12M:autoextend:max:500M
innodb_log_group_home_dir = /home/nwn/mysqldata/instA/innodb/log
innodb_buffer_pool_size = 32M
# MyISAM
key_buffer_size = 16M
server_id = 1
I did all the other configurations.
when I run following command
mysql-8.0]$ bin/mysqld --defaults-file=~/mysqldata/instA/my.cnf --initialize-insercure
I have following logs in the error_log
cat ~/mysqldata/instA/logs/instA-errorlog.err
2018-10-09T10:39:51.127424Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8160)
2018-10-09T10:39:51.127523Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 432 (requested 4000)
2018-10-09T10:39:51.383986Z 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
2018-10-09T10:39:51.384043Z 0 [System] [MY-010116] [Server] /home/nwn/mysql/mysql-8.0/bin/mysqld (mysqld 8.0.12) starting as process 32654
2018-10-09T10:39:51.386625Z 0 [Warning] [MY-010122] [Server] One can only use the --user switch if running as root
2018-10-09T10:39:51.394675Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2018-10-09T10:39:51.394817Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2018-10-09T10:39:51.394831Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-10-09T10:39:51.395363Z 0 [System] [MY-010910] [Server] /home/nwn/mysql/mysql-8.0/bin/mysqld: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.
Even though the post is very old, but posting my solution as it took me around 2 hours to figure it out and this can help someone save that time.
You can try doing :
shell> mysqld --initialize
This shall initialse the data directory in the path where you have installed MySql server. Generally placed at C:\Program Files\MySQL\MySQL Server 8.0.
Hope it helps someone.
Please follow these steps to reset your MySQL Password on Windows:
Stop MySQL Service # services.msc
Create file change_mysql_pwd.txt with following content (replase YourNewPassword with desired new password you want to have for root user:
ALTER USER 'root'#'localhost' IDENTIFIED BY 'YourNewPassword';
Save the file under C:\ change_mysql_pwd.txt
Run CMD.exe as Admin (Start->Cmd->Right Click->Run as Administrator)
Type in cmd: cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
Create “Data” Folder under "C:\Program Files\MySQL\MySQL Server 8.0\ (if already exists delete its contents!)
Type in cmd: mysqld --install
Type in cmd: mysqld --initialize
Type in cmd: mysqld --init-file=C:\\change_mysql_pwd.txt
Login with root user account and the password set above.
Delete C:\ change_mysql_pwd.txt file
Enjoy...
(context: new setup, mysql 8 on windows server 2016)
What really helped me to get rid of "Failed to find valid data directory" was:
mysqld --initialize --console
The --console part tells you straight away on the command line what is wrong and what to do. Because I had a clean install, i lacked the "data" directory. However if you have settings in your my.ini that are not supported in the newly installed version, a "data" directory will be generated nevertheless with the command listed above. If you have more then one faulty setting in my.ini, you'll need to delete the newly created "data" directory first.
CAUTION: check first if you have databases in the data directory, else you'll loose all your databases!! So only use this on fresh installs.
In steps:
run mysqld --initialize --console from a cmd as administrator
fix the my.ini faulty line, delete the data directory (ONLY IF YOU HAVE A NEW INSTALLATION: else you'll loose all your databases!)
rerun mysqld --initialize --console
repeat until all errors are fixed.
Now MySql should start.
As far as I understand from your console output you try to initialize the database while there exist files in your data directory. First you should remove all files (please be careful here, you may loss your data) in the data directory of your MySQL, and then you should run the command below
shell> mysqld --initialize --console
as stated by #Alex Karshin, #Lazycoder_0071 and #Freeze_H. MySQL should initialize the database seamlessly if there isn't another problem.
What Kevin Kopf and Lazycoder_007 indicate in https://stackoverflow.com/a/62003723/7733418 worked for me fine, along with
deleting the files within the "data" folder before initialization (thanks to P D)
running mysqld --initialize in cmd as administrator

Mysql server can not start as root

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

two installs of mysql on osx?

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.

Having issues starting MySQL Daemon

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!

Categories