Add Google Allow-List to MySQL Server Config File - mysql

Despite extensive searching, I have not found the syntax for adding ~70 URLs in the Google Allow-List to the my.ini config file, presumably using some form of bind-address?
Although I have successfully established a connection, using bind-address=0.0.0.0, I would like to restrict access to that list.
Should they be entered as one long comma-separated string after the bind-address= statement?

MySQL 8.0.13 and higher support a comma-separated list of IP addresses as the value of bind-address.
Documentation: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_bind_address
Older versions of MySQL don't support this feature. Run SELECT VERSION(); If it's less than 8.0.13, you must either upgrade to the current version of 8.0.x, or else solve this with a firewall of some kind (e.g. iptables), instead of MySQL's bind-address option.

Related

MySQL 8.0.3 defaults file missing in a running instance

Due to some configuration issue, I found out that I need to change a MySQL server parameter. However, MySQL was running in Windows "Services" as "C:\MySQL\bin\mysqld MySQL" which I understand does not provide a "defaults-file".
My question is,
Is there a default "defaults file" ? I searched for any *.ini or *.cfg file and could not find any.
Is there a sample file for this version I can download somewhere ? I tried some old files but there are some compatibility issues with previous versions.
Thanks in advance
MySQL Server has "default defaults" built-in. No options file is necessary to get these defaults.
You can find all the default values for every option in the manual: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html
It's recommended to leave the defaults alone unless you have a specific reason to change one. Then make your own edits to your local options file.
It's a good idea to add comments to the options file so you have a record of why you changed each value away from its built-in default.

How can I get 'max_statement_time' as a global variable in a GCP Cloud Sql mysql 5.6 instance?

As of mysql version 5.7.8, the variable max_statement_time was renamed to max_execution_time. I have an application that checks the database version and sets the correct variable according to that version number.
When I configure my application to use a local mysql installation, everything is fine, but when I configure it to use Google Cloud Sql, it works on 5.7, but fails on 5.6. The error it gives is:
java.sql.SQLException: Unknown system variable 'max_statement_time'
From a mysql shell I ran show variables like 'max%time' and got these results:
mysql 5.7 via percona: max_execution_time
mysql 5.7 via google max_execution_time
mysql 5.6 via percona max_statement_time
mysql 5.6 via google [empty]
I see that google has documentation about these flags here but max_statement_time doesn't appear in the list. Is there something I can do to force that flag to appear so that my application can set it an proceed happily?
Cloud SQL is a Google managed service. You do not have access to change all the mysql flags freely. Here there is the list of flags that you can see/ modify. If max_statement_time is not in that list it you cannot do anything related to it.
My recommendation is to use max_execution_time flag instead of max_statement_time. As it is mentioned in the documentation:
For a given flag, Cloud SQL might support a different range than the corresponding MySQL parameter or option.
The flags/ limations are not the same for CloudSQL with a simple MySQL database.

Validate UTF-8 MySQL before upgrade | SonarQube

SonarQube's install guide says that UTF-8 must be set when setting up MySQL. Is there a way I can check if my MySQL instance is compatible before attempting the upgrade?
I've done a few checks and we seem to have UTF8 setup for the client, connection, results, and system. At the database and server level we have swedish case insensitive. We do have UTF8_general_ci set for the collation_collection.
This instance will not be used in a multi language situation (only Us English). Do my settings align with what they should or do I need to spin up an entirely new instance?
You need to configure the url using jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 (see for example here). Read also the MySql Character Set Configuration documentation page. The settings are used by the SonarQube program, plugins and upgradescripts.

How to force case sensitive table names?

I'm working on a MySQL database in windows.
I must move it into a Linux environment. MySQL database contains a lot of tables and stored procedures which are CASE SENSITIVE.
When I backup my database, all table names are forced lowercase so when I restore it in Linux it complains because you can't make duplicate tables and stored procedures.
I don't have access to the MySQL configuration in the linux environment so I cant change MySQL settings to case insensitive mode.
Is there any way to force MySQL (v5.x) to use case sensitive table names in windows?
Read the following chapter in the official MySQL documentation: Identifier Case Sensitivity.
Then add the following system variable to the server section, [mysqld], inside the my.ini configuration file and restart the MySQL service:
lower_case_table_names=2
Have a look at this article - http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html
Mode 2 allows to store tables with specified lettercase, but anyway, name comparisons won't be case sensitive and you won't be able to store table1 and Table1 at the same time.
On Windows put lower_case_table_names=2 at the end of the
C:\ProgramData\MySQL\MySQL Server 5.7\my.ini file.
Unfortunately there's no way of making MySQL on windows to behave 100% as in Linux. What you can do, is to run a minimal VM on Virtual Box or VMware player with TurnKey - MySQL Appliance.
In my personal experience, I've found quite useful to have a VM with a configuration similar to the deployment environment to diagnose problems.
Add this property to lower_case_table_names=2 to my.ini
By default, table names are case sensitive in Windows, but you can make it case sensitive by updating the lower_case_table_names variable to 2.
ref: https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html
However, before going to the further process, create backups of your existing databases. Then you need to remove all existing databases to avoid table name inconsistency.
We were on the step to set lower_case_table_names to 2, but this variable is read-only, so you can not update it using the script. So need to change it to the configure file (my.ini). For windows, it's available in the C:\ProgramData\MySQL\MySQL Server X.X directory. Open this file in administrator mode and set the lower_case_table_names variable value to 2.
These changes will not take effect until you restart the MySQL server before restarting the MySQL Server by following steps.
Open the Run window by using the Windows+R keyboard
Type services.msc and press Enter
Select the MySQL service and click the restart button
ref: https://www.mysqltutorial.org/mysql-adminsitration/restart-mysql/
MySQL server might not start because of changes in the my.ini file. In that case, we can not proceed further. Therefore lower_case_table_names variable value set back 1 again. then restart the MySQL server mentioned above.
Finally, we only have one remaining option to make a case-sensitive table name for MySQL in windows, completely removing MySQL from your machine and configuring it during installation. During install, check Advanced and Logging Options from the Type and Networking tab, then select the radio button to preserve the given case from the Advanced Options tab.
ref: Can't set lower_case_table_names in MySQL 8.x on Windows 10
i add this line and it solve the different case problem
lower_case_table_names=1
in /etc/my.cnf
you can see how to set mysql variable "lower_case_table_names" form this page :
https://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_lower_case_table_names
In MySQL 8, lower_case_table_names setting is not allowed once installation is done. To enable the setting , you have to re-install mysql

How to enable inno-db support on MySql 5 installed above MySql 4?

How to enable inno-db support on installed instance of MySql?
I have installed mysql-5.0.67-win32.
'InnoDB' is 'DISABLED' when executing 'show engines'.
According to documentation MySql is compiled with support of inno-db
(From doc: A value of DISABLED occurs either because the server was started with an option that disables the engine, or because not all options required to enable it were given.)
In my.ini I commented line with 'skip-innodb'. This didn't help.
All other inno-db related variables remain unchanged.
I have performed some unusual action before I experienced described situation.
I have mysql-4.0.17-win installed. I uninstall it and after this installed mysql-5.0.67-win32.
In installation wizard I chose MyISAM support only (as far as I understand I disabled inno-db support in such way. When I tried to reinstall with support of inno-db I had problems of using my previous database 'mysql' with account information).
MySQL documentation says that I should use mysqldump to export data and after this to import exported data in process of upgrade. I tried to do so, but when importing data I obtained message about syntax error (I think that it is connected with some incompatibilities of 4-th and 5-th version of mysql)
Should be enabled by default. There are some situations where wrong permissions on the MySQL lib folder cause InnoDB to bark. Check your MySQL error log for permission errors.
I do have the following innodb options in my.ini. It is a very minimal configuration, so dont' use this values if you would like mysql to have a good performance. Please restart mysql after a change of my.ini.
#*** INNODB Specific options ***
innodb_data_home_dir="C:/mysqldata/"
#skip-innodb
innodb_additional_mem_pool_size=120M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=16M
innodb_buffer_pool_size=10M
innodb_log_file_size=2M
innodb_thread_concurrency=8
Maybe you have inno-db disabled in the global configuration file. On Linux this would be something like /etc/mysql/my.cnf - maybe Windows has a similar global conf-file.
Make sure you are changing the correct my.ini file. On Windows this is read from many locations. The order is:
WINDIR\my.ini, WINDIR\my.cnf
C:\my.ini, C:\my.cnf
INSTALLDIR\my.ini, INSTALLDIR\my.cnf
defaults-extra-file
Type mysql --help in the command prompt to see the actual order on your computer e.g.:
Default options are read from the
following files in the given order:
C:\my.ini C:\my.cnf C:\WINDOWS\my.ini
C:\WINDOWS\my.cnf C:\Program
Files\MySQL\M ySQL Server 5.0\my.ini
C:\Program Files\MySQL\MySQL Server
5.0\my.cnf
have you checked the startup parameters? maybe the shell script or batch file that you use to start up the server disable the engine on the command line.. IIRC command line flags trumps the .ini settings.
I have resolved the problem.
In short:
I was not able to dump databases on MySql4 and restore it on MySql5 due to some strange syntactic errors when importing data.
I tried after installation to override MySql5 databases with old ones, including database 'mysql'. It works ok but I was not able to enable inno-db support. (In such way I even was able to use function PASSWORD for old passwords (instead of OLD_PASSWORD))
Since database structure of 'mysql' is changed in 5 version I tried to install MySql5 again and copied my old databases except 'mysql' one. After this I updated 'mysql' database with corrected version of exported data from 'mysql'. In such a way I obtained mysql 5 working.
After all I also executed mysqlcheck --all-databases --auto-repair
to upgrade my tables.
P.S. Thank to authors of all answers which hint me to the correct way of resolving problem.