How do you refresh the MySQL configuration file without restarting? - mysql

Apache has such a feature, what about MySQL?
Does one exist?

You were so close! The kill -HUP method wasn't working for me either.
You were calling:
select ##global.max_connections;
All you needed was to set instead of select:
set ##global.max_connections = 400;
See:
http://www.netadmintools.com/art573.html
http://www.electrictoolbox.com/update-max-connections-mysql/

Try:
sudo /etc/init.d/mysql reload
or
sudo /etc/init.d/mysql force-reload
That should initiate a reload of the configuration. Make sureyour init.d script supports it though, I don't know what version of MySQL/OS you are using?
My MySQL script contains the following:
'reload'|'force-reload')
log_daemon_msg "Reloading MySQL database server" "mysqld"
$MYADMIN reload
log_end_msg 0
;;

Reloading the configuration file (my.cnf) cannot be done without restarting the mysqld server.
FLUSH LOGS only rotates a few log files.
SET ##...=... sets it for anyone not yet logged in, but it will go away after the next restart. But that gives a clue... Do the SET, and change my.cnf; that way you are covered. Caveat: Not all settings can be performed via SET.
New with MySQL 8.0...
SET PERSIST ... will set the global setting and save it past restarts. Nearly all settings can be adjusted this way.

Specific actions you can do from SQL client and you don't need to restart anything:
SET GLOBAL log = 'ON';
FLUSH LOGS;

Related

icmp_echo_ignore_all doesn't get set

I'm trying to set icmp_echo_ignore_all to 1, and I am able to do so using the following:
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
I've also edited the sysctl.conf file and added:
net.ipv4.icmp_echo_ignore_all = 1
and then I followed with this:
sysctl -p
Supposedly the last two steps would permanently set icmp_echo_ignore_all to 1, until the next time I enable it. Every time I reboot, though, it goes back to 0. Am I missing a step? I'm doing it on a virtual machine running Ubuntu 14.04 LTS.
Any advice would be greatly appreciated.
For me this did only get set after I issued sysctl -w to set the setting, as opposed to editing sysctl.conf manually.
I found that most other settings in sysctl.conf are picked up on reboot as sysctl.conf is linked also as /etc/sysctl.d/99-sysctl.conf
For some reason this one isn't - or it is, but later in the boot process gets overwritten - so after a boot I usually manually issue sysctl -w again.

Why can't I change sql_mode permanently?

I an currently using mysql server 5.6 in windows 10. while using mysql, an error keeps appearing that goes as something like this "the following column does not have a default value" i read on the internet that i can solve this problem if i change the sql_mode. It is currently set to
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
I took this from "my-default.ini" file in "mysql server 5.6" folder. I read several other answers that say that if you want to permanently change your sql_mode, you should do it through the "my-default.ini" file. So what i did was, i run my notepad as administrator, then i browsed to open "my-default.ini" file that is found in:
c:\programs files (x86)\mysql\mysql server 5.6\my-default.ini
when i opened the file, i modified the last line:
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
to
sql_mode=
then i saved the file, closed it. then by using task manager i restarted my sql sever:
task manager >> services >> mysql56
This is the whole process that should permanently modify my sql_mode. when i look in my "my-default.ini" file, the last line is still modified. but if i log into mysql through the command line and view my sql_mode with the following code:
select ##sql_mode;
I get that my sql_mode is
STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
I want all this to be removed (permanently) in order for my error to disappear. IF i try to modify the sql_mode from the command line by using:
set ##global.sql_mode="";
It worked, but when i restarted MySQL, everything was back as it was before.
Can someone please tell me what i am doing wrong? and if there is another way to solve this problem.
UPDATE: Sorry, forgot you were using Windows 10. I'm not sure how to deal with this issue in Windows but maybe try copying my-default.ini to my.ini and changing that setting. Sorry for confusion.
Not sure if you can set your sql_mode to nothing but try changing the value in your /etc/mysql/my.cnf file. If that folder/file doesn't exist, create it and try setting sql_mode under [mysqld] like this:
[mysqld]
sql_mode=
I just did this same thing only I set the sql_mode to NO_ENGINE_SUBSTITUTION.
If you have MySQL Workbench installed, check the Server Status for the base directory of your instance. You should find a my.ini file there that keeps your changes.
sql_mode need to add to file /etc/init.d/mysql as a argument to start like:
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --sql-mode="" $other_args >/dev/null 2>&1 &
Restart MySQL database server to apply new config.
In MYSQL 8 and ubuntu server 20.xx I had to add:
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTIO
To file
/etc/mysql/mysql.conf.d/mysqld.cnf
In order that the setting stay persistent after server restart
Disclaimer:
this was the only place it actually worked, I have no idea what's the good practice where to add these custom settings but it 'ain't stupid if it works'. Somebody can tell me.
I tried the other options I found on forums:
my.cnf did not work creating
custom cnf did not work
adding it to mysql.cnf did not work

Use environment variables in my.ini/my.cnf

Is it possible to read env vars in MySQL option file my.ini/my.cnf, the way it is possible in httpd.conf and php.ini with the ${ENVVAR} syntax :
datadir="${MYSQL_DATA_HOME}/Data/"
If yes, what is the syntax ?
I think it is not possible. I tried making the same changes in MySQL option file, but failed to start. But there is another way though.
Set MYSQL_DATA_HOME=<some dir> in the console. And in the same terminal start mysql not by service start but with this command mysqld --datadir=$MYSQL_DATA_HOME/whatever

Cannot login to phpMyAdmin, no errors shown

I have MySQL set up correctly on my linux computer, however I want a better way to input data into the database besides terminal. For this reason, I downloaded phpMyAdmin. However, when I try to log in to the phpMyAdmin from index.php, it doesnt do anything. It seems to just refresh the page without doing anything. I am putting in the correct MySQL username and password. What is the issue?
Here is a screen shot of what it shows after I click "go".
This is a possible issue when the path to save php_session is not correctly set :
The directory for storing session does not exists or php do not have sufficient rights to write to it.
To define the php_session directory simply add the following line to the php.ini :
session.save_path="/tmp/php_session/"
And give write rights to the http server.
usually, the http server run as user daemon in group daemon. If it is the case, the following commands will make it :
chown -R :daemon /tmp/php_session
chmod -R g+wr /tmp/php_session
service httpd restart
Login fails if session folder in not writeable. To check that, create a PHP file in your web directory with:
<?php
$sessionPath = 'undefined';
if (!($sessionPath = ini_get('session.save_path'))) {
$sessionPath = isset($_ENV['TMP']) ? $_ENV['TMP'] : sys_get_temp_dir();
}
if (!is_writeable($sessionPath)) {
echo 'Session directory "'. $sessionPath . '"" is not writeable';
} else {
echo 'Session directory: "' . $sessionPath . '" is writeable';
}
If session folder is not writeable do either
sudo setfacl -R -m u:www-data:rwx <session directory> or chmod 777 sudo setfacl -R -m u:www-data:rwx <session directory>
-
I am late to the game, but on Amazon linux AMI I could not log in to phpmyadmin ... it just kept refreshing the login screen with no errors.
I have fixed with below command
sudo chmod -R 755 /var/lib/php/session
I fixed my issue on CentOS 7 with MariaDB and phpmyadmin I downloaded from offical phpmyadmin site by adding
session.save_path = "/var/lib/php/session"
to /etc/php.ini
and
chown -R :lighttpd /var/lib/php/session
I also restarted php-fpm and lighttpd after
In my case the solution was to set an Apache setting properly:
ProxyPassReverseCookiePath
This was required, because ProxyPass and ProxyPassReverse were in use, but cookie paths are not changed automatically.
It'd be great if PHPMyAdmin had shown something like session not found or anything, when password is sent with POST.
Do you have a .htaccess file in one of the parent directories that strips off index.php from the url by doing a 301 redirect?
301 redirects discard the form data and redirect you as if you didn't submit anything. So you get returned to the login page.
So you should create a local .htaccess file in the phpmyadmin directory with a single line RewriteEngine On. This will overwrite the previous rewrite rule to nothing.
You may need to clear the browser cache as Chrome aggressively caches 301 redirects.
In my case the hard drive was full.
Use df -h to check the space left on your hard drive, and if you want you can free some space by using the command sudo apt-get clean, which removes installation files.
I hope this will help some future users.
I ran these commands and it worked for me:
sudo service httpd restart
sudo service mysqld stop
sudo service mysqld start
Try searching the web for installation or setup guides for phpMyAdmin. Look at two or three of these and make sure you have covered all the required steps. (If you have already done so, please include which guides you have followed it in the question).
See if it helps to edit config.inc.php (acecoder mentioned this as well).
Check if this guide is of any help.
Which distro are you on? Try searching for the name of the distro you are using together with "phpMyAdmin guide" or "phpMyAdmin setup howto".
If you encounter errors along the way, post the error text here, if it's short (or paste via a pastebin-like site if it's long).
Are you sure that mysql is running? I had the same issue after doing a database import and filling up the volume containing the mysql database. After changing various permissions and clearing sessions, I tried to restart mysql (/etc/init.d/mysql restart) and it failed because the volume was full. After increasing /var and starting mysql successfully, I was able to log into phpmyadmin just fine.
If you have an error like:
Host 'host_name' is blocked because of many connection errors.
Login in your mysql as root and run the flush hosts command
1.- mysql -u root -p
2.- mysql > flush hosts
After this I was able to login again in phpmyadmin
phpMyAdmin will show errors when login fails. If it doesn't, it means that your setup has an error.
The most likely place to check is your php.ini settings. Since there doesn't seem to be an official list of phpMyAdmin-compatible settings, it's mostly trial and error.
Make sure you have enabled the stuff that needs to be enabled. Also check that you did not enable uncommon php.ini settings (like enable_post_data_reading = Off) because phpMyAdmin assumes them to be "the usual ones".
To ease debugging, start with a clean default php.ini file then tweak them line by line to see which setting is causing the error. (Don't forget that you need to restart your server after changing the php.ini file for the changes to take place.)
In my case it was due to an old Apache session.
Stop Apache, clear all pending sessions in your sessions.save_path directory (example: /var/lib/php/session) and restart Apache.
Make sure to set a 32 chars long random key in 'config.inc.php' in the $cfg['blowfish_secret'] value. That solved it for me.
Didn't realize I need to restart MariaDB after modifying config.inc.php:
service mariadb restart
Otherwise at least in my case changes didn't come affect. Also make sure your php session directory is writable by webserver (typically session.save_path = "/var/lib/php/session")

mysqld hangs when init-file used in my.cnf

I am trying to do some stuff every time mysqld (version 5.1.4) is started/restarted on Fedora14.
I put the following line in my.cnf:
init-file=/etc/mysqlinit.sql
I've tried various queries in the file, even leaving the file empty.
MySQL will not start ... I get Timeout error occurred trying to start MySQL Daemon.
I've tried enclosing the path in quotes and have ensured file permissions are same as my.cnf.
I've tried moving the file around.
Nothing in the mysqld or messages logs to help.
I wonder if selinux has to be turned off.
Did I miss something?
change the ownership and group of the /etc/mysqlinit.sql file (and dirs) to match the one mysqld (the deamon not the config file) is running under and try again, enable the error_log to see the output of the error.