Issue when running mysqld - mysql

I download mysql-5.7.9-winx64.zip and when i try to run mysqld i got this error :
E:\Softwares\mysql-5.7.9-winx64\bin>mysqld
mysqld: Could not create or access the registry key needed for the MySQL application
to log to the Windows EventLog. Run the application with sufficient
privileges once to create the key, add the key manually, or turn off
logging for that application.
mysqld: Can't change dir to 'E:\Softwares\mysql-5.7.9-winx64\data\' (Errcode: 2 - No such file or directory)
2015-11-13T10:45:09.715411Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_ti
mestamp server option (see documentation for more details).
2015-11-13T10:45:09.731411Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of
generated files. Consider setting it to a valid, non-empty path.
2015-11-13T10:45:09.732411Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
2015-11-13T10:45:09.732411Z 0 [Note] mysqld (mysqld 5.7.9) starting as process 3532 ...
2015-11-13T10:45:09.864419Z 0 [Warning] Can't create test file E:\Softwares\mysql-5.7.9-winx64\data\yous-PC.lower-test
2015-11-13T10:45:09.864419Z 0 [Warning] Can't create test file E:\Softwares\mysql-5.7.9-winx64\data\yous-PC.lower-test
2015-11-13T10:45:09.864419Z 0 [ERROR] failed to set datadir to E:\Softwares\mysql-5.7.9-winx64\data\
2015-11-13T10:45:09.865419Z 0 [ERROR] Aborting
2015-11-13T10:45:09.865419Z 0 [Note] Binlog end
2015-11-13T10:45:09.945424Z 0 [Note] mysqld: Shutdown complete

You must run the Command Prompt as administrator. Then run mysqld.
To do this right click the Command Prompt startup icon and then select Run As Admininistrator. Then run mysqld and you should no longer see that error.
mysqld needs access to your registry the first time. you do not have to do this after the first time.

For development/debugging purposes i need a MySQL-Server without installation and don't want it to change my windows installation, e.g. by setting registry keys. MySQL's hint "start server with --log_syslog=0" works well:
mysqld -u root --log_syslog=0

try the MySQL Installer 5.7.9 to install it automatically mysql-installer-web-community-5.7.9.0.msi and it works.

Windows operating system will not allow you to make changes in certain system critical registry keys. Nevertheless, if you want to make changes even in such registry keys, you will have to take full control of these keys before Windows will allow you to make or save the changes.
check this link:
http://www.thewindowsclub.com/how-to-take-full-control-of-windows-7-registry-keys

I ran into the same problem on a Windows machine. I tried to "Run as Administrator" and change the path, but nothing prevailed.
It turned out Mysql wasn't reading the "my.ini" file.
I solved the problem by putting the "my.ini" file into the C:/Windows directory as it was pointed out in the official MySQL troubleshoot guide HERE

I run into both log error and data folder misconfig issues like you have.
Here is my solution:
Run the Command Prompt as administrator. Then run mysqld. - (just like user1660791 suggested)
For the path error, you need to make sure to \ instead of \ for path.
Example as below:
basedir = C:\\myfolder\\mysql-5.7.11-winx64
Have to post this as new answer due to i don't have permission comment of others post.

Use basedir = C:/myfolder/mysql-5.7.11-winx64 then find cmd.exe for the path: C:\Windows\System32\cmd.exe.
In order to do this, right click the Command Prompt startup icon and then select "Run As Admininistrator".

Related

Configuring multiple instances of mysqld on almalinux

I've been trying to setup multiple instances of mysqld on an almalinux box.
I can't get the systemctl start mysqld#replica03 statements to recognize the associated options setup in the /etc/my.cnf file.
If I change the [mysqld#replica03] or [mysqld#replica04] to [mysqld] it works and uses the appropriate datadir and port. As soon as I use [mysqld#replica03] and [mysqld#replica04] in the /etc/my.cnf file it uses the default /var/lib/msyql datadir and options instead of the ones I specified
I have run
systemctl enable mysqld#replica03
systemctl enable mysqld#replica04
Any ideas would be appreciated.
/etc/my.cnf file:
[client-server]
[mysqld#replica03]
server_id=3
port=3306
datadir=/var/lib/mysql_replica03
socket=/var/lib/mysql_replica03/mysql.sock
log-error=/var/log/mysql_replica03/mysqld.log
pid-file=/var/run/mysqld_replica03/mysqld.pid
[mysqld#replica04]
server_id=4
port=3307
datadir=/var/lib/mysql_replica04
socket=/var/lib/mysql_replica04/mysql.sock
log-error=/var/log/mysql_replica04/mysqld.log
pid-file=/var/run/mysqld_replica04/mysqld.pid
When you need multiple instances, and you're using systemd to achieve it, the server option groups configuration is the way to go.
The comment you made on your question shows that the suffix used is prefixed with a dot.
ExecStart=/usr/libexec/mysqld --defaults-group-suffix=.%I
So the server groups should be rewritten to
[mysqld.replica03]
server_id=3
port=3306
datadir=/var/lib/mysql_replica03
socket=/var/lib/mysql_replica03/mysql.sock
log-error=/var/log/mysql_replica03/mysqld.log
pid-file=/var/run/mysqld_replica03/mysqld.pid
[mysqld.replica04]
server_id=4
port=3307
datadir=/var/lib/mysql_replica04
socket=/var/lib/mysql_replica04/mysql.sock
log-error=/var/log/mysql_replica04/mysqld.log
pid-file=/var/run/mysqld_replica04/mysqld.pid
Another important observation is that the order in configuration files matters. Theses replica servers definitions need to be parsed after main [mysql] section.
my_print_defaults will help you with it:
$ my_print_defaults --defaults-group-suffix=.another mysqld
--datadir=/var/lib/mysql
--socket=/var/lib/mysql/mysql.sock
--log-error=/var/log/mariadb/mariadb.log
--pid-file=/run/mariadb/mariadb.pid
--datadir=/db/another/mysql
--socket=/db/another/mysql/mysql.sock
--log-error=/db/another/log/mariadb/mariadb.log
--pid-file=/run/mariadb/mariadb-another.pid
$
If your OS has a /etc/my.cnf.d/ directory, as mine does, you will need to sort the filenames in order to accommodate this requirement.
As I'm using mariadb, and I have a /etc/my.cnf.d/mariadb-server.cnf, my another server group is on a file named zz-another.cnf, making sure it will be parsed after mariadb-server.cnf.

PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start

when i try to start the zabbix-server i am getting and run/zabbix/zabbix_server.pid not readable (yet?) error,
ls -al
-rw-rw-r--. 1 zabbix zabbix 5 May 1 15:15 zabbix_server.pid
my zabbix-server config file
#This is a configuration file for Zabbix Server process
# To get more information about Zabbix,
# visit http://www.zabbix.com
############ GENERAL PARAMETERS #################
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
#PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
Please help. suggest me a solution
I've had this issue when building a zabbix 4.0 server. To fix the issue I made sure that the path to the PID file was correct on '/etc/zabbix/zabbix_server.conf' and '/lib/systemd/system/zabbix-server.service'.
Interestingly restarting the service alone did not get rid of the error. I needed to reboot the server and this fixed the problem.
close the selinux on centos7
It works for me.
just close selinux for this time
setenforce 0
Close selinux forever
vi /etc/selinux/config
SELINUX=disabled
That message only indicates that the server failed to start. Check the server log (/var/log/zabbix/zabbix_server.log according to your config file), it will contain a more meaningful error message.
In my case, it was a issue connecting with the database.
Remove current pid file + be sure that no zabbix_server process is running on your machine.
Zabbix server does not accept special chars like: !##$%^&*()_+,./;'[]}{|":?>< in DBPassword variable.

can timestamp be stored in the mysql history file /root/.mysql_history?

I am trying to identify the timestamp for the mysql command executed.
In the /root/.mysql_history file there is only command and no time is found.
Can a timestamp be stored in the mysql history file /root/.mysql_history in Linux using any configuration ?
If you invoke mysql --syslog, the client will write a log of the queries you execute in your system log, including the date & time.
On Linux this log is in /var/log/messages. On Mac, it's /var/log/system.log. On Windows, it's the Windows Event Log.
See https://dev.mysql.com/doc/refman/5.7/en/mysql-logging.html
You can also enable this option by default by editing /etc/my.cnf or your personal $HOME/.my.cnf:
[mysql]
syslog
I tried this in my VM, and I got the following in /var/log/messages. I tried twice, once using the command-line option and then with the config-file option.
Sep 19 16:09:30 sandbox-centos mysql: SYSTEM_USER:'vagrant', MYSQL_USER:'root', CONNECTION_ID:215, DB_SERVER:'127.0.0.1', DB:'--', QUERY:'select 'now is the time';'
Sep 19 16:10:02 sandbox-centos mysql: SYSTEM_USER:'vagrant', MYSQL_USER:'root', CONNECTION_ID:223, DB_SERVER:'127.0.0.1', DB:'--', QUERY:'select now();'
Of course any user can override this option, so it's pretty easy to cover one's tracks. In other words, you shouldn't rely on this as an auditing tool.

Executing a system command from mysql

I am trying to execute a shell command from within mysql (from within a procedure or a trigger or the command line for mysql).
I have added lib_mysqludf_sys to the mysql plugins and created the functions that are available with the library. (the library) home page
The library has 5 functions.
sys_set - to set $PATH - this works and stores the $PATH which i can later check.
sys_get - to get the stored value of $PATH - this also works and returns the value that I have stored.
sys_exec - to execute a command in the system and return the exit code.
sys_eval - to execute a command in the system and return the standard output.
lib_mysqludf_sys_info - return the current version of the library - this also works.
I need sys_exec and sys_eval to work correctly.
I think I have found the problem in my search but cannot solve it.
mysql is limited by apparmor and is not granted access to execute system commands by the default apparmor profile. I have tried the commands in the documentation to disable a single profile, disable the framework, putting all profiles except one into enforce mode and putting all profiles in complain mode. Nothing works. the command
sudo apparmor_status
always gives me the same output.
20 profiles are loaded.
20 profiles are in enforce mode.
/opt/extras.ubuntu.com/unity-lens-askubuntu/unity-askubuntu-daemon
/sbin/dhclient
/usr/bin/evince
/usr/bin/evince-previewer
/usr/bin/evince-previewer//launchpad_integration
/usr/bin/evince-previewer//sanitized_helper
/usr/bin/evince-thumbnailer
/usr/bin/evince-thumbnailer//sanitized_helper
/usr/bin/evince//launchpad_integration
/usr/bin/evince//sanitized_helper
/usr/lib/NetworkManager/nm-dhcp-client.action
/usr/lib/connman/scripts/dhclient-script
/usr/lib/cups/backend/cups-pdf
/usr/lib/lightdm/lightdm/lightdm-guest-session-wrapper
/usr/lib/telepathy/mission-control-5
/usr/lib/telepathy/telepathy-*
/usr/sbin/cupsd
/usr/sbin/mysqld
/usr/sbin/tcpdump
/usr/share/gdm/guest-session/Xsession
0 profiles are in complain mode.
5 processes have profiles defined.
5 processes are in enforce mode.
/sbin/dhclient (2537)
/usr/lib/telepathy/mission-control-5 (2709)
/usr/sbin/cupsd (12245)
/usr/sbin/cupsd (12250)
/usr/sbin/mysqld (12675)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
Please tell me how I could disable apparmor or change the profile for mysql so that it has access to executing system commands.
The reason I am doing all this is so that I can execute a system command when somethings happen in the DB (via a DB trigger), if you have suggestion for some other ways in which this can be easily implemented then please mention those too.
Thanks.
managed to get this working. First put apparmor in complain mode for the necessary profiles then used apparmor's interactive tools (aa-genprof/aa-logprof) to configure the profile for mysqld

Monit service name error

So I have the following in my monitrc file:
check process apache with pidfile /usr/local/apache/logs/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host XXX port 80 protocol http
and request "/monit/token" then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu 80% for 5 cycles then restart
if totalmem 500 MB for 5 cycles then restart
if children 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
but I keep getting the error that:
Error: service name conflict, apache already defined '/usr/local/apache/logs/httpd.pid'
If the hostname of the server is 'apache' then the conflict is with the default rule for monitoring the system load.
Monit seems to have the implicit rule of 'check system hostname', where the hostname is the output of hostname command.
You can overwrite that by adding just a line like:
check system newhostname
For example:
check system localhost
I saw this error when I forgot to comment out the line:
include /etc/monit/conf.d/*
in a custom /etc/monit/conf.d/myprogram.conf file, so it was recursively including that file.
By any chance do you have an entry with a host name apache beneath this entry or in a separate monit config file?
You have the same service defined more than once. Check all your monit config files for that service. This includes your monitrc and all files listed under the "Includes" section (like include /etc/monit/conf.d/*).
If you redefine "Includes" within a file in one of your "Includes" directories, you will run into recursive reference problems.
Very very important thing : you need monit 5.5
For example in ubuntu 12.04 available in repo only 5.3
So you need to download and install from other repo.
Solution for me , for example :
wget http://mirrors.kernel.org/ubuntu/pool/universe/m/monit/monit_5.5.1-1_amd64.deb && sudo dpkg -i monit_5.5.1-1_amd64.deb
For my case, I simply had to restart monit to get rid of the service name error:
sudo service monit restart
Check if you have had any conflicts for Apache defined in any of the monit conf files under /etc/monit.d/ directory, I accidentally did added nginx for my puma.conf and ran into the same error before.