Mac电脑安装mysql数据库的教程

在这里插入图片描述
Mac下修改MySQL初始密码
  停止 mysql server. 通常是在 ‘系统偏好设置’ > MySQL > ‘Stop MySQL Server’
  打开终端,输入:
  sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
  打开另一个新终端,输入:
  sudo /usr/local/mysql/bin/mysql -u root
  UPDATE mysql.user SET authentication_string=PASSWORD(‘新密码’) WHERE User=‘root’;
  FLUSH PRIVILEGES;
  \q
  重启MySQLMac下解决MySQL存储中文乱码问题
  第一步:在macbook进入终端后输入命令:
  show variables like ‘%character%’;
  在这里插入图片描述
   charactersetserver为latin1,导致了数据库无法显示中文
1、修改配置文件
创建一个 my.cnf 注意文件的后缀是.cnf
用高级记事本打开文件把下边代码复制到文件中
把文件移动到 /etc 目录下 利用command + shift + G 热键打开一个路径搜索框输入etc回车即可
[client]
default-character-set=utf8

For advice on how to change settings please see

http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

*** DO NOT EDIT THIS FILE. It’s a template which will be copied to the

*** default location during install, and will be replaced if you

*** upgrade to a newer version of MySQL.[mysqld]

character-set-server=utf8# Remove leading # and set to the amount of RAM for the most important data

cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging

changes to the binary log between backups.

log_bin# These are commonly set, remove the # and set as required.

basedir = …

datadir = …

port = …

server_id = …

socket = …# Remove leading # to set options mainly useful for reporting servers.

The server defaults are faster for transactions and fast SELECTs.

Adjust sizes as needed, experiment to find the optimal values.

join_buffer_size = 128M

sort_buffer_size = 2M

read_rnd_buffer_size = 2Msql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

2.重新启动mysql或者重启电脑

文章来自:https://www.itjmd.com/news/show-6377.html

猜你喜欢

转载自blog.csdn.net/a6984021/article/details/88532145