The server quit without updating PID file ' - mysql

I use the command:
/usr/local/Cellar/mysql/5.6.26/support-files/mysql.server start
to start the database and get the error info:
ERROR! The server quit without updating PID file(/usr/local/var/mysql/macbooks-MacBook-Pro.local.pid).
The local.err has the following information:
151103 20:43:37 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
2015-11-03 20:43:37 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-03 20:43:37 0 [Note] /usr/local/Cellar/mysql/5.6.26/bin/mysqld (mysqld 5.6.26) starting as process 42772 ...
2015-11-03 20:43:37 42772 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2015-11-03 20:43:37 42772 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/Cellar/mysql/5.6.26/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2015-11-03 20:43:37 42772 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

Your MySQL installation appears to be damaged. You have an error but the proposed resolution isn't likely to help:
/usr/local/Cellar/mysql/5.6.26/bin/mysqld: Can't find file: './mysql /plugin.frm'
(errno: 13 - Permission denied)
2015-11-03 20:43:37 42772 [ERROR] Can't open the mysql.plugin table.
Please run mysql_upgrade to create it.
As you see, MySQL cannot open a file, but not because it does not exist; rather because it has no rights to do so (error 13).
From the console, verify the status of the mysql/plugin.frm file in the 'mysql' directory. You'll need to find the MySQL data directory (mysql).
Supposing it's /usr/local/var/mysql/, you would do
ls -la /usr/local/var/mysql/ | more
(SPACE or ENTER to page the output) and see a row containing "plugin.frm".
If there is not, then running the mysql_upgrade command might fix things (but backup the mysql installation and data directory first! Just in case).
If there is, verify it has the same user and group as the other files. Chances are that the other files will be owned by Cellar/users and this, maybe, by root/wheel. As administrator (su), try running
chown Cellar:users ./mysql/plugin.frm
and this should fix the Errno 13, and possibly the PID trouble as well.
Failing everything else, reinstalling MySQL could be a solution. You'll install the same version 5.6.26, then verify the data directory and, if necessary, overwrite it with your backup, having care to preserve the new ownerships and permissions.
This trick isn't guaranteed to work between different MySQL versions and OSes, but on the same machine with the same MySQL version and OS it stands excellent chances.
You can also run a partial restore of only the databases you need (for example you can skip restoring the mysql tablespace where all users and permissions are. You'll lose them, but the data will still be accessible in the other databases).

Related

Dropped mysql database and now mysql service won't start

By mistake I dropped mysql database which contains configuration for mysql service itself and now the service won't start. Here is the log at startup :
100 200
2018-10-17T06:31:21.364556Z 0 [Warning] InnoDB: New log files created, LSN=2939944
wampmysqld64: Table 'mysql.plugin' doesn't exist
2018-10-17T06:31:21.748646Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-10-17T06:31:21.749764Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-10-17T06:31:21.754394Z 0 [Warning] Failed to open optimizer cost constant tables
2018-10-17T06:31:21.803432Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2018-10-17T06:31:21.804295Z 0 [ERROR] Aborting
Is there a way to restore it to the original without reinstalling everything (it was bundled in wamp server so I would have to reinstall everything).
To restore fresh mysql system after accidental removal of a system database you have to :
Rename or delete the data folder in mysql install folder otherwise the next step will yield an error.
Run one of these commands from windows console :
C:> bin\mysqld.exe --initialize
C:> bin\mysqld.exe --initialize-insecure

Cannot start Mysql 5.7 on cent 0s 6.10

I am trying to setup MySql 5.7 on CentOS 6.10. I've installed MySQL but when I try to run sudo service mysqld start, it is not starting. The error is
2018-11-05T17:14:57.569757Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-05T17:14:57.573328Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 10355 ...
2018-11-05T17:14:57.575610Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2018-11-05T17:14:57.575652Z 0 [ERROR] Aborting
2018-11-05T17:14:57.575671Z 0 [Note] Binlog end
2018-11-05T17:14:57.575741Z 0 [Note] mysqld: Shutdown complete
I guess it is something to do with selecting the user type as root but I'm not able to figure out what to do. Can someone help?Thanks in advance
It looks like mysqld is configured to run as the root user right now, which is not a recommended way for it to run--hence the hard warnings forcing you to change your configuration. You should instead run as the mysql user that was created for you when you installed the package.
You can see the user mysqld is set up to run under by looking in the [mysqld] section of my.cnf. It seems most likely you have user=root, or the command line flag of --user=root is being applied.
Best practice would be to configure it to use the non-privileged mysql user instead.
Relevant documentation:
The How to Run MySQL as a Normal User documentation page indicates that:
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.
MariaDB (a fork of MySQL) provides a documentation page called Running mysqld as root which indicates:
MariaDB should never normally be run as the system's root user (this is unrelated to the MariaDB root user). If it is, any user with the FILE privilege can create or modify any files on the server as root.
MariaDB will normally return the error Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! if you attempt to run mysqld as root. If you need to override this restriction for some reason, start mysqld with the user=root option.
Better practice, and the default in most situations, is to use a separate user, exclusively used for MariaDB. In most distributions, this user is called mysql.

I am having troubles with Mysql - "about query logging issue"?

i want to save the queries of my mysql to a .out/.log/.txt file on my desktop. I am using a Mac machine. i saw my friend use "tee" linux command in mysql to log the queries like
tee ~/Desktop/mylog.txt
above command worked on his laptop running windows but shows an error-
( Can't create/write to file '~/Desktop/mylog.txt' (Errcode: 2 - No such file or directory)
Error logging to file '~/Desktop/mylog.txt')
on my laptop. Once i tried with no file on my desktop to let it create one, then i pre-created one. but in both cases it was not working.
then i also tried this one below:-
mysqld --log=~/Desktop/myquery.log
this also doest work and gives an error:
mysqld: Can't change dir to '/usr/local/mysql-5.7.18-macos10.12-x86_64/data/' (Errcode: 13 - Permission denied)
2017-09-05T08:35:50.566311Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-05T08:35:50.567503Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2017-09-05T08:35:50.567630Z 0 [Note] mysqld (mysqld 5.7.18) starting as process 25981 ...
2017-09-05T08:35:50.602972Z 0 [Warning] Can't create test file /usr/local/mysql-5.7.18-macos10.12-x86_64/data/Lohitakshs-MacBook-Air.lower-test
2017-09-05T08:35:50.603050Z 0 [Warning] Can't create test file /usr/local/mysql-5.7.18-macos10.12-x86_64/data/Lohitakshs-MacBook-Air.lower-test
2017-09-05T08:35:50.603305Z 0 [ERROR] failed to set datadir to /usr/local/mysql-5.7.18-macos10.12-x86_64/data/
2017-09-05T08:35:50.603328Z 0 [ERROR] Aborting
2017-09-05T08:35:50.606324Z 0 [Note] Binlog end
2017-09-05T08:35:50.608285Z 0 [Note] mysqld: Shutdown complete
Then i also tried by going SUDO , but that also gave the same error.
Now my problem is that i have too many queries on my screen right now, which i cannot afford to loose, so i need a solution which can solve the issue on my running server.
Thanks a lot
The mysql program doesn't understand the ~ shorthand for your home directory.
If you're in your home directory when you run the mysql command, you can simply type
mysql> tee Desktop/mylog.txt
If not, you'll need to type the full path.
mysql> tee /Users/yourusername/Desktop/mylog.txt

Mysql doesn´t start after expending data-dir with simlink to another database

I´ve installed mysql and it worked fine.
Now I´d liked to have the data of several databases in my dropbox. So I put symlinks in my mysql data dir.
sudo ln -s /Users/michaelbenker/Dropbox/geschaeft/softwareentwicklung/DB/testdatabase /usr/local/mysql/data/testdatabase
Now when I tried to restart mysql, I get the error
ERROR! MySQL server PID file could not be found!
Starting MySQL
. ERROR! The server quit without updating PID file
(/usr/local/mysql/data/Michaels-iMac-783.local.pid).
In my error file I found this entry
2017-05-26T11:29:12.067923Z 0 [ERROR] InnoDB: Operating system error
number 13 in a file operation.
2017-05-26T11:29:12.067928Z 0 [ERROR] InnoDB: The error means mysqld
does not have the access rights to the directory.
2017-05-26T11:29:12.067934Z 0 [ERROR] InnoDB:
os_file_readdir_next_file() returned -1 in directory ./, crash recovery
may have failed for some .ibd files!
2017-05-26T11:29:12.067963Z 0 [ERROR] InnoDB: Plugin initialization
aborted with error Generic error
2017-05-26T11:29:12.375057Z 0 [ERROR] Plugin 'InnoDB' init function
returned error.
2017-05-26T11:29:12.375090Z 0 [ERROR] Plugin 'InnoDB' registration as a
STORAGE ENGINE failed.
2017-05-26T11:29:12.375097Z 0 [ERROR] Failed to initialize plugins.
2017-05-26T11:29:12.375100Z 0 [ERROR] Aborting
So I tried several things to change the permission to my Dropbox data-dir
I tried to change the owner to mysql (tried also _mysql)
I tried to change the group to mysql (tried also _mysql)
I tried to change the chmod to 777
Nothing helped.
I did the same on my MacBook and here everything worked fine.
Here the actual permissions on the Dropbox Dir
drwxrwxrwx# 5 _mysql _mysql 170 26 Mai 13:02 DB
MySQL will also need to be able to change into the parents of the Dropbox directory, which implies a +x on each one.

Building MySQL as non-root and with another MySQL already running

I need to use a bioinformatics tool that uses MySQL. The tool is called SyMap. When I try to run SyMap, it tells me there's a MySQL server already running so I should either shut it down or point SyMap to another server. Since I work on an HPC that allows me limited permissions, I cannot shutdown the MySQL server. So I've been trying to build my own local MySQL server. With zero knowledge about MySQL, this has been frustrating.
I tried to follow this guide to build MySQL as a non-root user with the addition of the flag MYSQL_TCP_PORT=3307 to the cmake command to have the local server run on a different port than the original's (3306). Whenever I get to the step where I have to execute mysql_install_db, it says:
2015-10-31 20:52:02 [WARNING] mysql_install_db is deprecated. Please
consider switching to mysqld --initialize 2015-10-31 20:52:02 [ERROR]
Child process: /home/rajeha/software/mysql/bin/mysqldterminated
prematurely with errno= 32 2015-10-31 20:52:02 [ERROR] Failed to
execute /home/rajeha/software/mysql/bin/mysqld --bootstrap
--datadir=/home/rajeha/software/mysql/data --lc-messages-dir=/usr/share/mysql --lc-messages=en_US
-- server log begin -- 2015-11-01T01:52:02.964453Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead 2015-11-01T01:52:02.969334Z 0 [ERROR] Invalid old_passwords mode: 1.
Valid values are 2 and 0
2015-11-01T01:52:02.969376Z 0 [ERROR] Aborting
-- server log end --
I also tried to run the ./bin/mysqld --initialize --user=mysql command, but I still get the error that old_passwords is equal to 1.
If I try to run the server with mysql_safe, it says:
*./bin/mysqld_safe: line 130: /var/log/mysqld.log: Permission denied ./bin/mysqld_safe: line 164: /var/log/mysqld.log: Permission denied
151031 20:53:12 mysqld_safe mysqld from pid file
/home/rajeha/software/mysql/the.pid ended ./bin/mysqld_safe: line 130:
/var/log/mysqld.log: Permission denied*
This is because it's trying to access /var/log/ which I cannot write onto. I probably have to change the config file that tells mysql to access this directory, and that also specifies the value of old_passwrods, but I don't know where to find it.
I would appreciate your help.
Thanks.