MySQL installation and tossing-encoding settings, mysql tossing-Encoding
1. Install MySQL
Download Mac OS X 10.12 (x86, 64-bit), DMG Archive (https://dev.mysql.com/downloads/mysql/) edition from the official website (mysql-5.7.19-macos10.12-x86_64.dmg), double click to install as prompted, after installation, you can start and close the MySQL server in the control panel,
Install the client at the same time: MySQL Workbench. app, (download link: https://dev.mysql.com/downloads/file? Id = 468289)
Start the MySQL server, open MySQL Workbench, enter the initial password, and then prompt to change the initial password.
2. Set the logon path under Terminal:
In/Users/**/create a file:. bash_profile
File input:
export PATH=${PATH}:/usr/local/mysql/bin
Save it. Under Terminal, you can use mysql-u root-p to log on.
Iii. database coding problems
Log on to the MySQL client (mysql-u root-p) in Terminal to view the database code. The command is as follows:
mysql> SHOW VARIABLES LIKE 'char%';
Found
character_set_database | latin1
character_set_server | latin1
Encoding settings are required, but the installation file does not contain the my. cnf file. Many solutions on the Internet are useless. You can only create my. cnf files.
Close the MySQL server and use MacVim to create my. cnf. The input content is:
# Example MySQL config file for medium systems. # # This is 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. # You can copy this option file to one of those # locations. For information about these locations, see: # http://dev.mysql.com/doc/mysql/en/option-files.html # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option. # The following options will be passed to all MySQL clients [client] default-character-set=utf8 #password = your_password port = 3306 socket = /tmp/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] character-set-server=utf8 init_connect='SET NAMES utf8 port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M character-set-server=utf8 init_connect='SET NAMES utf8' # Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (via the "enable-named-pipe" option) will render mysqld useless! # #skip-networking # Replication Master Server (default) # binary logging is required for replication log-bin=mysql-bin # binary logging format - mixed recommended binlog_format=mixed # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id = 1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave, you can choose between # two methods : # # 1) Use the CHANGE MASTER TO command (fully described in our manual) - # the syntax is: # # CHANGE MASTER TO MASTER_HOST=
Save and save the file to the/etc/directory. Restart the mysql server to make the modification successful,
If you still cannot insert Chinese characters, create a new database and table.
Reference: http://www.jianshu.com/p/628bcf8bb557