How to change default MySQL database/table default COLLATION using WampServer? - mysql

just want to ask about my problem. My problem is everytime I created a database. It's default collation is always set to 'latin1_swedish_ci'. But what I want is set this to 'utf8_general_ci' in DEFAULT. I also added this to my my.ini file in mysql:
character-set-server=utf8
collation-server=utf8_general_ci
But it is default in latin1_swedish_ci.

According to the manual, the my.ini is just about the only place where you cannot change this setting. You can either:
Change the startup parameters - pass ---character-set-server=latin1 etc. to the startup invocation.
Recompile with a different default - probably not really practical with WAMP
Change the values at runtime. This only changes them for the session though, and is as such rather pointless for these config values.
I'd look into option 1 for a local WAMP machine.

Related

lower_case_table_names set to 2, Workbench still does not allow lowercase database name

I have installed MySql Workbench 6.2 with MySql version 5.6 on my Windows 7 64-bit.
I would like to use Capital letters in my database name and table names. So I need to set the variable lower_case_table_names to 2. When I look at my Options file's General tab, it looks like the following:
Clicking Apply opens a dialog that says "There Are No Changes".
Regardless, when I try to create a database with a Capital letter, I get the warning:
The server is configured with lower_case_table_names=1 which only
allows lowercase characters in schema and table names.
I have a feeling the my.ini file on the server differs from the one mentioned in the Options File configuration. When I try to add this variable manually
inside my my.ini file, I see the text below:
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
This is how I have been stuck in creating my schema for a few days now.
In Windows, table naming is case-insensitive. That is, your Customer table and your customer table will always be the same on Windows. That's a limitation of the NT File System. This applies when your MySQL server is running on a Windows platform. It doesn't matter where your workbench client is running.
(You can use mixed-case table names for different tables on Linux, BSD, and the like, but it's considered very bad practice: only do that if you want to drive your colleagues crazy. So be careful.)
If you leave this lower_case_table_names setting alone, you can use mixed case in your table names without problems.
The my.ini file the server actually uses when it starts is usually found in the data directory. The installation procedure can copy a preloaded version of that file, like my_large.ini on top of my.ini depending on what you are trying to do.
You can't even start mysqld after changing the lower_case_table_names setting other to anything other than 1, which is the default.
0 => You should not set lower_case_table_names to 0 if you are running MySQL on a system where the data directory resides on a case-insensitive file system (such as on Windows or macOS). It is an unsupported combination that could result in a hang condition.
But let's try changing it to 2:
# Specifies the on how table names are stored in the metadata.
# If set to 0, will throw an error on case-insensitive operative systems
# If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive.
# If set to 2, table names are stored as given but compared in lowercase.
# This option also applies to database names and table aliases.
# NOTE: Modify this value after Server initialization won't take effect.
lower_case_table_names=2
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqld
--defaults-file="C:\Program Files\MySQL\MySQL Server 8.0\my.ini"
ERROR [MY-011087] [Server, Different lower_case_table_names settings for server ('2') and data dictionary ('1').
ERROR [MY-010020] [Server, Data Dictionary initialization failed.
After initialization, it is not allowed to change this setting.
So lower_case_table_names needs to be set together with --initialize.
It is prohibited to start the server with a lower_case_table_names setting that is different from the setting used when the server was initialized. The restriction is necessary because collations used by various data dictionary table fields are based on the setting defined when the server is initialized, and restarting the server with a different setting would introduce inconsistencies with respect to how identifiers are ordered and compared.
mysqld --initialize --console --lower_case_table_names=2
Then you will get following error in workbench after initilizing the server again with lower_case_table_names=2:
A server configuration problem was detected. The server is in a system that does not properly support the selected lower_case_table_names option value. Some problems may occur.
show variables like lower_case_table_names;
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_table_names | 2 |
So conclusion: on Windows leave the setting to 1 because 0 or 2 won't work or as they put it: some problems may occur.
I do however now have my database and table names showing up with Capital letters.
Which doesnt really do much because comparison will always be :
# If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive.
# If set to 2, table names are stored as given but compared in lowercase.
Nicholas
If your data files are on a drive different than the C: drive, you may actually have 2 "my.ini" files, one will be on the C: drive and when you edit the Options in Workbench, that is the file that gets changed while the "My.ini" your system is actually working from is left alone.
Check C:\Program Data\MySQL\MySQL(server version), to see if there is an .ini file there. If so, you will probably find it has the changes at the bottom of the file that need to be written to the actual working .ini on the drive your data is really stored on.
In workbench go to : management panel > Options File > General > System >
Check the "lower_case_table_names", put value 2.
Close Workbench.
Restart Service MYSQL56
See img here How to enable
Edit this file at /etc/mysql/my.cnf
Add following lines:
[mysqld]
lower_case_table_names=1
Restart mysql sudo /etc/init.d/mysql restart

(64 bit windows) timestamp error when trying to run MySQL database and set password

I am very new to servers in general and even cmd prompt. Anyways I downloaded MySQL and I am watching this video to set up MySQL at 8:21 in the video is my problem https://www.youtube.com/watch?v=O4xXzTIcnDE. When I type in -intmysql -u root -p i get a warning like this.
[WARNING] TIMESTAMP with implicit DEAULT value is deprecated
I found a few other post that i had to add some timestamp setting to a file. I am running 64 bit so none of these worked. Any ideas on how i can get past this timestamp issue? Thanks.
I don't think that's an error. That's just a warning. You could "turn off" that warning with a startup option (the message lines following the warning at startup tell the setting that needs to be changed...
Those nonstandard behaviors remain the default for TIMESTAMP but as of MySQL 5.6.6 are deprecated and this warning appears at startup:
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option (see
documentation for more details).
As indicated by the warning, to turn off the nonstandard behaviors, enable the new explicit_defaults_for_timestamp system variable at server startup. With this variable enabled, the server handles TIMESTAMP as follows instead:
http://dev.mysql.com/doc/refman/5.6/en/upgrading-from-previous-series.html
The options file is typically named my.cnf file, but on Windows, it may be named my.ini. (So, first, you need to know where the options file is for your installation, and then modify it,
Under the [mysql] section, add explicit_defaults_for_timestamp
[mysql]
explicit_defaults_for_timestamp
That change will become effective the next time MySQL server is started.
If you are loading scripts for tables from older versions of MySQL, those scripts may be dependent on the older, deprecated behavior.

MySql General Query Log

Does restarting the MySQL service on Linux, disables the already enabled general query logging?
There was a log file getting generated inside the data folder, and it was growing exponentially. The db has 100 requests per minute.
Initially i guessed, some transaction had broken in between, that made the logs to swell.
So i restarted the service, which stopped adding to that log file.
I checked the global variables and got to know the path was assigned for general_log_file. But now it was showing 'OFF'.
Hence my query
It's a common issue that people will set configuration of MySQL through dynamic (global) variables and forget to set the variables in the options file (my.conf). In that case, when the server is restarted, MySQL will revert to default settings.
The default setting for general_log is OFF. To immediately enable the general query log, set the global variable to ON. Then set the value for general-log in your my.conf file to ensure that the setting is applied whenever you restart MySQL server.
No, Restarting the server doesn't make the binary logs to OFF...
It may be the case that you changed the configuration file before and now restart takes that file...
MySQL will start with whatever options are in the file configuration. If you switched any of the global server variables before, they will be reverted to what is set in the file.

How to switch old-passwords OFF in Mysql 4.1

I am having a hard time migrating my MySQL 4.1 database from old 16-byte password hashes to the new 41-byte hashes. The problem is, that the mysqld server automatically starts with the "old-passwords = on" directive, which restricts setting new passwords to 41-bytes length.
My question: Does anyone know how I can tell mysqld to run without the "old-passwords = on" directive? I tried my.ini, commmandline, setting the variable locally, but nothing worked.
Thanks a lot!
Philipp
The first thing to check is the width of the user table Password field in the mysql database. Prior to 4.1 this was 16 characters wide. When upgrading to 4.1 the width should have been changed to 41 characters by means of the mysql_upgrade utility provided. If that step was missed for some reason the server would default to using the old 16-byte hashes, which is the behaviour you describe.
There's a write up of this in the MySQL docs.
If you find that your table does need to be updated from char(16) to char(41) and you have the mysql_update utility, run that to complete the upgrade. Alternatively (take a backup and then you can) update manually using:
ALTER TABLE user
MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default ''

How to enable STRICT_ALL_TABLES' for single MySQL database?

Is there a way to enable STRICT_ALL_TABLES for a single MySQL database?
set sql_mode = 'STRICT_ALL_TABLES'; will do it.
You can set the default SQL mode by starting mysqld with the --sql-mode="modes" option, or by using sql-mode="modes" in my.cnf (Unix operating systems) or my.ini (Windows). modes is a list of different modes separated by comma (“,”) characters. The default value is empty (no modes set). The modes value also can be empty (--sql-mode="" on the command line, or sql-mode="" in my.cnf on Unix systems or in my.ini on Windows) if you want to clear it explicitly.
ref MySql Website
Don't think you can do this directly but you might get close with setting Strict for the current session when working on a particular database. Could do this in the config files of specific users.