vahid najafi vahid najafi - 1 month ago 7
MySQL Question

phpmyadmin server variables and session values

I'm going to use

utf8mb4
. Also some of my variables must be utf8mb4 that mentioned here. I set them from phpmyadmin
Variables
menu. But some of changes to utf8mb4 but it's session value is still
uft8
.

enter image description here

And when I run this command:

SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'


That show me utf8, not utf8mb4. Any idea?

EDIT: When I set the a variable to
utf8
, session value disapear.

Answer

To establish permanent changes to these, or any other, "Variables":

  1. Edit my.cnf
  2. restart the server (mysqld)
  3. (obviously) you will then need to log in again.

The flow:

  • When the server starts, my.cnf is used to override builtin defaults; the combination becomes the GLOBAL VARIABLES.
  • When you connect, the global variables are used to initialize the SESSION VARIABLES; these are used by your connection.
  • If you do a SET, it will modify only your session variable. The value will be lost when the connection closes.

Another note on utf8mb4... Most client software (php, phpmyadmin, etc) has a way of setting the CHARACTER SET and COLLATION for the connection. This is when you should establish that "the bytes in the client are "UTF-8" encoded. (The outside world calls it UTF-8; MySQL calls the same thing utf8mb4.)

Comments