Ubuntu12.04. After MySQL is installed, an error is returned when the character compilation is changed. I feel very depressed. Environment: root @ ubuntu :~ # Uname-aLinuxubuntu3.2.0-23-generic #36-effectusmptueapr1020: 39: 51UTC2012x86_64x86_64x86_64GNU/apt-getinsta for Linux
In Ubuntu 12.04, MySQL is installed. After MySQL is installed, an error is returned when the character compilation is changed. I feel very depressed.
Environment:
Root @ ubuntu :~ # Uname-
Linux ubuntu 3.2.0-23-generic # 36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
The apt-get install mysql-server is installed, and then the default character set is changed in/etc/mysql/my. default-character-set = utf8 is added to [mysqld] and [client] In cnf, and cannot be restarted.
Root @ ubuntu :~ # Service mysql start
Start: Job failed to start
After reading the system log, the following content is reported:
Jun 11 22:56:42 ubuntu kernel: [4051.584941] init: mysql main process (4021) terminated with status 7
Jun 11 22:56:42 ubuntu kernel: [4051.584981] init: mysql main process ended, respawning
Jun 11 22:56:43 ubuntu kernel: [4052.134766] init: mysql post-start process (4022) terminated with status 1
Jun 11 22:56:43 ubuntu kernel: [4052.154739] type = 1400 audit (1339469803.511: 40 ): apparmor = "STATUS" operation = "profile_replace" name = "/usr/sbin/mysqld" pid = 4068 comm = "apparmor_parser"
Jun 11 22:56:44 ubuntu kernel: [4053.619246] init: mysql main process (4072) terminated with status 7
Jun 11 22:56:44 ubuntu kernel: [4053.619296] init: mysql main process ended, respawning
Jun 11 22:56:45 ubuntu kernel: [4054.248707] init: mysql post-start process (4073) terminated with status 1
Jun 11 22:56:45 ubuntu kernel: [4054.269778] type = 1400 audit (1339469805.627: 41 ): apparmor = "STATUS" operation = "profile_replace" name = "/usr/sbin/mysqld" pid = 4119 comm = "apparmor_parser"
Jun 11 22:56:47 ubuntu kernel: [4055.733347] init: mysql main process (4123) terminated with status 7
Jun 11 22:56:47 ubuntu kernel: [4055.733389] init: mysql respawning too fast, stopped
Root @ ubuntu :~ #
After a long struggle, I accidentally tested it today and accidentally solved the problem. Haha, I have to say that the RP broke out.
The configuration file is as follows:
Root @ ubuntu:/etc/mysql # cat/etc/mysql/my. cnf | grep-v '^ #'
[Client]
Default-character-set = utf8 # You do not need to specify it here. To specify it, use this command.
Port = 3306
Socket =/var/run/mysqld. sock
[Mysqld_safe]
Socket =/var/run/mysqld. sock
Nice = 0
[Mysqld]
Character_set_server = utf8 # To Use this command, default-character-set = utf8 will report an error
User = mysql
Pid-file =/var/run/mysqld. pid
Socket =/var/run/mysqld. sock
Port = 3306
Basedir =/usr
Datadir =/var/lib/mysql
Tmpdir =/tmp
Lc-messages-dir =/usr/share/mysql
Skip-external-locking
Bind-address = 127.0.0.1
Key_buffer = 16 M
Max_allowed_packet = 16 M
Thread_stack = 192 K
Thread_cache_size = 8
Myisam-recover = BACKUP
Query_cache_limit = 1 M
Query_cache_size = 16 M
Expire_logs_days = 10
Max_binlog_size = 100 M
[Mysqldump]
Quick
Quote-names
Max_allowed_packet = 16 M
[Mysql]
[Isamchk]
Key_buffer = 16 M
! Includedir/etc/mysql/conf. d/
Root @ ubuntu:/etc/mysql #
We can see that in the [client] and [myslqd] segments, the instructions used to set character encoding are different.
Restart mysql.
Root @ ubuntu:/etc/mysql # service mysql restart
Mysql stop/waiting
Mysql start/running, process 6981
Root @ ubuntu:/etc/mysql # mysql-uroot-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 147
Server version: 5.5.22-0ubuntu1 (Ubuntu)
Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> show variables like '% char % ';
+ -------------------------- + ---------------------------- +
| Variable_name | Value |
+ -------------------------- + ---------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | utf8 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | utf8 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +
8 rows in set (0.00 sec)