Edit MySQL encoding format under Mac Terminal--my-default.cnf and my.cnf not found

Source: Internet
Author: User
Tags unique id

First, make sure that MySQL is properly installed.

1-Configure the environment variable path first

1.1 Open terminal, input: CD ~

Will enter the ~ folder,

1.2 then enter:touch. Bash_profile

After the carriage return is executed,

1.3 Re-enter:open-e. Bash_profile

This file is opened in TextEdit (this should be a blank document if the environment variable has not been previously configured).

If you have content, enter it before the Terminator, and if there is no content, enter the following statement directly:

      Export Path=${path}:/usr/local/mysql/bin

Then, save, Exit TextEdit (must be exited), close the terminal and exit.

You should now be able to log in to MySQL directly with the following statement


1.4 Turn off MySQL!!!! (Turn MySQL off in System Preferences)

2-The emphasis came!!!

2.1 View the Support-files folder ("Go to Folder" under Finder; path:/usr/local/mysql/support-files)

There are no my-default.cnf or my.cnf files ... If available, open the add directly

Under [client], add the Default-character-set=utf8 default character set to UTF8
Add in [mysqld]
Default-character-set=utf8 default character set is UTF8
init_connect= ' Set NAMES UTF8 ' (when setting up a MySQL database using UTF8 encoding to let the MySQL database run for UTF8), restart MySQL to view the current data encoding format. >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/|

If the terminal appears as the upper style is OK, otherwise continue to look down:

2.2 Support-files Folder There is no my-default.cnf or my.cnf file, then you need to create a new my.cnf in/etc

      $ cd/etc

      $ sudo vim my.cnf

2.3 After the last step will enter the VIM mode, at this time copy (* * * text) content pasted in, (does not contain * * * text);

2.4 Paste success after the attention to see the first line of vim "#" has not lost (I have lost ~ ~ haha ~), all OK, click ESC Exit Edit,

      : wq! --force exit after saving. [With several editing commands:DD Delete the line of the cursor; DW Deletes a word (word); x Delete the current character].

(* * * text):

# Example MySQL config file for medium systems.
# This was for a system with little memory (32m-64m) where MySQL plays
# An important part, or systems up to 128M where MySQL is used together with
# Other programs (such as a Web server)
# MySQL programs look for option files in a set of
# Locations which depend on the deployment platform.
# can copy this option file to one of those
# locations. For information on these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
# In the This file, you can use the all long options, which a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options would be passed to all MySQL clients
#password = Your_password
Port = 3306
socket =/tmp/mysql.sock
# Here follows entries for some specific programs
# the MySQL server
init_connect= ' SET NAMES UTF8
Port = 3306
socket =/tmp/mysql.sock
key_buffer_size = 16M
Max_allowed_packet = 1M
Table_open_cache =
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
init_connect= ' SET NAMES UTF8 '
# Don ' t listen on a TCP/IP port at all. This can is a security enhancement,
# If all processes this need to connect to mysqld run on the same host.
# All interaction with Mysqld must is made via Unix sockets or named pipes.
# Note that the using this option without enabling named Pipes on Windows
# (via the "enable-named-pipe" option) would render mysqld useless!

# Replication Master Server (default)
# Binary logging is required for replication

# Binary Logging format-mixed recommended

# required Unique ID between 1 and 2^32-1
# defaults to 1 if master-host are not set
# but would not function as a master if omitted
Server-id = 1

# Replication Slave (Comment out Master sections to use this)
# To configure the host as a replication slave, you can choose between
# methods:
# 1) Use the Change MASTER to command (fully described with our manual)-
# The syntax is:
# change MASTER to Master_host=
# master_user=<user>, master_password=<password>;
# where you replace the
# <port> by the master's port number (3306 by default).
# Example:
# change MASTER to master_host= ' 125.564.12.1 ', master_port=3306,
# master_user= ' Joe ', master_password= ' secret ';
# OR
# 2) Set the variables below. However, in case you choose the This method, then
# Start replication for the first time (even unsuccessfully, for example
# If you mistyped the password in Master-password and the slave fails to
# Connect), the slave would create a master.info file, and any later
# change in this file to the variables ' values below 'll be ignored and
# Overridden by the content of the Master.info file, unless you shutdown
# The slave server, delete master.info and restart the slaver server.
# for this reason, want to leave the lines below untouched
# (commented) and instead use change MASTER to (see above)
# required Unique ID between 2 and 2^32-1
# (and different from the master)
# defaults to 2 if Master-host is set
# but would not function as a slave if omitted
#server-id = 2
# The replication Master for this slave-required
#master-host =
# The username the slave would use for authentication when connecting
# to the master-required
#master-user = <username>
# The password The slave would authenticate with when connecting to
# The Master-required
#master-password = <password>
# The Port The master is listening on.
# optional-defaults to 3306
#master-port = <port>
# binary Logging-not required for slaves, but recommended

# Uncomment the following if you is using InnoDB tables
#innodb_data_home_dir =/usr/local/mysql/data
#innodb_data_file_path = Ibdata1:10m:autoextend
#innodb_log_group_home_dir =/usr/local/mysql/data
# you can set: _buffer_pool_size up to 50-80%
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set: _log_file_size to% of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout =

Max_allowed_packet = 16M

# Remove The next comment character if you is not a familiar with SQL

Key_buffer_size = 20M
Sort_buffer_size = 20M
Read_buffer = 2M
Write_buffer = 2M


Edit MySQL encoding format under Mac Terminal--my-default.cnf and my.cnf not found

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.