MySQL安装之编码设置的图文详解

一、mysql的安装

  从官网中下载Mac OS X 10.12 (x86, 64-bit), DMG Archive(mysql-5.7.19-macos10.12-x86_64.dmg)版,双击按提示安装,安装完成后可在控制面板下启动关闭MySQL服务器,

MySQL安装之编码设置的图文详解

  同时安装客户端:MySQL Workbench.app,

MySQL安装之编码设置的图文详解

  启动MySQL服务器,打开MySQL Workbench,输入初始密码,随即提示修改初始密码。

二、设置Terminal下登录路径:

  在/Users/**/新建文件:.bash_profile

  文件中输入:

export PATH=${PATH}:/usr/local/mysql/bin

   保存即可。在Terminal下,即可使用”mysql -u root -p”进行登录。

文心快码 文心快码

文心快码(Comate)是百度推出的一款AI辅助编程工具

文心快码 35 查看详情 文心快码

三、数据库编码问题

      在Terminal中登录MySQL客户端(mysql -u root -p)查看数据库编码,命令如下:

mysql> SHOW VARIABLES LIKE 'char%';

  发现

character_set_database | latin1character_set_server | latin1

  需要进行编码设置,但安装文件里无my.cnf文件,网上很多解决方法都没用,只能自建my.cnf文件。

  关闭MySQL服务器,使用MacVim创建my.cnf,输入内容为:

# 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=, MASTER_PORT=,      #    MASTER_USER=, MASTER_PASSWORD= ;      #      #    where you replace , ,  by quoted strings and      #     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 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 will create a master.info file, and any later      #    change in this file to the variables' values below will 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 that reason, you may 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 will not function as a slave if omitted      #server-id       = 2      #      # The replication master for this slave - required      #master-host     =         #      # The username the slave will use for authentication when connecting      # to the master - required      #master-user     =         #      # The password the slave will authenticate with when connecting to      # the master - required      #master-password =         #      # The port the master is listening on.      # optional - defaults to 3306      #master-port     =        #      # binary logging - not required for slaves, but recommended      #log-bin=mysql-bin        # Uncomment the following if you are 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 25 % 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 = 50          [mysqldump]          quick          max_allowed_packet = 16M            [mysql]            no-auto-rehash            # Remove the next comment character if you are not familiar with SQL            #safe-updates            default-character-set=utf8           [myisamchk]          key_buffer_size = 20M          sort_buffer_size = 20M          read_buffer = 2M          write_buffer = 2M            [mysqlhotcopy]            interactive-timeout

  保存并将文件存在至/etc/目录之下,重启mysql服务器,即修改成功,

            如果还是不能插入汉字,请重新创建数据库和表。

以上就是MySQL安装之编码设置的图文详解的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/391978.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年11月6日 16:05:47
下一篇 2025年11月6日 16:06:45

相关推荐

  • MySQL ERROR 1045出现的原因及怎么解决

    在命令行输入mysql -u root –p,输入密码,或通过工具连接数据库时,经常出现下面的错误信息,相信该错误信息很多人在使用mysql时都遇到过。 ERROR 1045 (28000): Access denied for user ‘root’@’loca…

    2025年12月5日 数据库
    000
  • linux上安装docker容器和mysql镜像拉取的方法

    docker pull xxxx 拉取镜像 docker run -it xxxx /bin/bash 启动镜像 启动docker服务 docker ps 查询运行中的容器 docker ps -a 查询所有容器,包括未运行的 mysql容器启动:docker run -itd –nam…

    数据库 2025年12月5日
    000
  • ubuntu下mysql 8.0.28怎么安装配置

    修改密码改了挺长时间,记录下安装过程 安装ssh服务: sudo apt-get install openssh-server 启动ssh服务: service sshd start 安装mysql服务器端: sudo apt install -y mysql-server 安装mysql客户端: …

    2025年12月5日
    000
  • MySQL事件调度器如何使用_能实现哪些自动化任务?

    mysql事件调度器是内置的定时任务工具,用于自动化周期性操作。一、开启方法:用show variables查看event_scheduler状态,若为off则在配置文件添加event_scheduler=on或临时执行set global开启;二、创建语法:create event定义触发时间、频…

    2025年12月5日 数据库
    000
  • mysql临键锁如何使用

    1、默认情况下,innodb使用临键锁锁定记录。 select … for update 2、当查询索引包含唯一属性时,临键锁将被优化并降级为记录锁,即只锁定索引本身,而不是范围。 3、不同场景下的临键锁会退化。 实例 事务1 start transaction;select SLEEP(4);…

    数据库 2025年12月5日
    000
  • MySQL命令行中如何修改MySQL密码

    方法一: mysql admin -u 用户名 -p 旧密码 passw 新密码 ‘u’为 username 的简称,‘p’为原 password 简称。 方法二: 我们先登录 MySQL 数据库。之后输入: mysql>set password for root@localhost = pa…

    数据库 2025年12月5日
    000
  • MySQL8如何设置自动创建时间和自动更新时间

    业务场景: 1、在数据库表中的数据,要求记录每一条新增数据的创建时间,时间格式要求明确至:年月日:时分秒。 2、在数据库表中的数据,要求记录每一条更新数据的更新时间,时间格式要求明确至:年月日:时分秒。 功能实现: 1、为每张业务表添加create_time 和update_time 字段,且将字段…

    数据库 2025年12月5日
    000
  • mysql InnoDB的四种锁定范围是什么

    1、记录锁,锁定索引中的记录。 2、间隙锁。 要么锁定索引记录中间的值,要么锁定第一个索引记录前面的值,要么锁定最后一个索引记录后面的值。 3、临键锁,是索引记录上的记录锁和索引记录前的间隙锁的组合。 4、插入意向锁,在insert操作中添加记录id的锁。 实例 — id 列为主键列或唯一索引列U…

    数据库 2025年12月5日
    000
  • MySQL中FROM_DAYS函数怎么用

    FROM_DAYS(date) SELECT FROM_DAYS(367) -> 0001-01-02 返回西元0年至今多少天的DATE值 以上就是MySQL中FROM_DAYS函数怎么用的详细内容,更多请关注创想鸟其它相关文章!

    数据库 2025年12月5日
    000
  • rocks mysql数据库多实例数据库配置的示例分析

    mysql数据库默认路径修改 启动httpd服务 mkdir -p /run/httpdsystemctl start httpd.service 1.什么是多实例? 在linux系统中代表:多个进程+多个线程+多个预分配内存结构 一般用来测试环境中,测试主从,高可用等。 多实例配置方案:(多个数据…

    数据库 2025年12月5日
    000
  • Linux怎样查看mysql密码

    相信很多小伙伴都经历过忘记密码,如果在Linux下忘记MySQL密码该怎么办? Linux查看mysql密码具体方法。 查看默认密码 grep ‘temporary password’ /var/log/mysqld.log 或者 cat /var/log/mysqld.log | grep ‘te…

    数据库 2025年12月5日
    000
  • MySQL数据库的基本操作实例分析

    一、MySQL简介 1、数据库管理软件分类 主要分为关系型和非关系型。 可以简单的理解为,关系型数据库需要有表结构,非关系型数据库是key-value存储的,没有表结构。 关系型:如sqllite,db2,oracle,access,sql server,MySQL,注意:sql语句通用。 非关系型…

    数据库 2025年12月5日
    000
  • mysql内连接查询实例分析

    1、分为隐式内连接查询和显示内连接查询,通过是否包含inner join关键字进行区别。 2、主表和从表中的数据都是满足连接条件则能够查询出来,不满足连接条件则不会查询出来。 实例 — 2.1 隐式内连接方式select *from t_category c, t_product p WHERE …

    数据库 2025年12月5日
    000
  • MySQL中binlog/redolog/undolog区别是什么

    MySQL binlog/redolog/undolog 的区别? 想和大家聊聊 innodb 中的锁机制,那么不可避免的要涉及到 mysql 的日志系统,binlog、redo log、undo log 等,看到有小伙伴总结的这三个日志还不错,赶紧拿来和各位小伙伴分享。 日志是mysql数据库的重…

    2025年12月5日 数据库
    000
  • phpstudy安装后mysql无法启动如何解决

    原因分析 我去网上查找phpstudy和mysql冲突的问题, 哦原来是 这两个mysql都占用的是3306端口, 而系统原来的mysql会开机启动(就是这里,会让原来的mysql作为服务开机启动监听)。那么当你打开phpstudy的时候, 便会再启动一个mysql服务,这个时候因为是同一个端口的关…

    2025年12月5日
    000
  • MySQL与PHP中的内置函数怎么用

    MySQL 内置函数 mysql 内置函数可以帮助我们更方便的处理表中的数据, 简化操作. 数学函数: 函数 描述 ABS()取绝对值SQRT()取根号MOD()取模FLOOR()返回不大于的最大整数值CELLING()返回不小于的最小整数值ROUND()四舍五入SIN()取正弦COS()取余弦 字…

    2025年12月5日
    000
  • 怎么在MySQL中设置时间

    MySQL支持多种时间格式,其中包括DATE、TIME、DATETIME和TIMESTAMP。这四种格式都有其特定的用途。 DATE格式表示日期,格式为“YYYY-MM-DD”,其中“YYYY”表示年份,“MM”表示月份,“DD”表示日期。 TIME格式表示时间,格式为“HH:MM:SS”,其中“H…

    数据库 2025年12月5日
    000
  • 如何安装和配置ThinkPHP开发环境?

    如何安装和配置thinkphp开发环境?首先,安装php 7.2+和web服务器(如xampp或wamp);其次,使用composer安装thinkphp框架;最后,配置应用和web服务器指向thinkphp的public目录。 在开始我们的ThinkPHP之旅前,让我们先回答一个关键问题:如何安装…

    2025年12月5日
    000
  • mysql左外连接查询的语法是什么

    1、以join左表为主表,显示主表的所有数据,并根据条件查询连接右表的数据。如果满足条件,则显示;如果不满足,则显示为null。 2、可以理解为在内部连接的基础上,确保左表的所有数据都显示。 语法 select 字段 from a left [outer] join b on 条件 实例 使用左连接…

    数据库 2025年12月5日
    000
  • 基于springboot+bootstrap+mysql+redis怎么搭建完整的权限架构

           首先将已经封装好的bootstrap脚本引入到我们现有的工程,目录如下:        到此我们的bootstraop框架引入完成,那么基于bootstrap框架我们现在开始开发属于我们的第一个bootstrap页面登陆页,打开我们的templates文件在底下找到我们login.ht…

    2025年12月5日 数据库
    100

发表回复

登录后才能评论
关注微信