search

Home  >  Q&A  >  body text

Mysql cannot run after modifying my.cnf? ? ?

The following is the entire content of my.cnf:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

Then add two sentences to modify the characters:

[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8

Then it won’t work

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
仅有的幸福仅有的幸福2814 days ago602

reply all(1)I'll reply

  • 某草草

    某草草2017-06-06 09:53:57

    • Comment out the two newly added sentences with # and try to see if it can be started (to rule out newly introduced configuration errors)

    • Run mysqld status to view the current startup status of Mysql (excluding failure to start due to not shutting down)

    • Have the permissions of the running user changed? For example, it used root before and now uses user (to rule out permission issues)

    If it can be started in the first step, it means there is a problem with the new configuration. Check whether the startup parameters are written incorrectly according to the Mysql version, as shown above.

    reply
    0
  • Cancelreply