Mac安装MySQL8.0解压版 以及安装MySQL8.0解压常见的问题

Mac上安装MySQL8.0

1。下载 https://downloads.mysql.com/archives/community/

2. 解压

3.新建个配置文件 安装根目录下新建 my.cnf  或者 在/etc目录下新建 my.cnf

文件实例

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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]

# 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.
#设置mysql的安装目录
basedir = /usr/local/develop/mysql-8.0.24
#设置mysql的数据存放目录
datadir = /usr/local/develop/mysql-8.0.24/data 
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
character-set-server=utf8mb4


# 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 = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 


[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4

4.同时修改 根目录下 my.cnf 该文件的 权限  chmod 644 ./my.cnf 

5.因为配置文件中指定了MySQL data存放目录 在根目录下创建 data 目录   mkdir data

6.cd bin  在bin目录下进行初始化 MySQL

7.执行 mysqld --initialize --console

8.执行后保存临时密码 

9.同样还是bin目录  mysqld --user=root start  强制使用 使用root用户来启动MySQL 

10.配置MySQL 环境变量  

11.登录mysql  mysql -u root -p   输入之前保存的临时密码  临时忘了 也没关系 重新删除MySQL的data目录 在回到7步骤 重新初始化

12.临时密码登录成功 会要求你修改密码 不然 无法进行其他操作 

13. 修改密码为 root  MySQL命令行内 执行  alter user 'root'@'localhost' identified by 'root';

14.这下可以愉快的使用MySQL了  如有问题 欢迎私信

正文结束 

问题1.

自己新建的配置文件权限全局可写,任何一个用户都可以写。mysql担心这种文件被其他用户恶意修改,所以忽略掉这个配置文件

解决

my.cnf设置为用户可读写,其他用户不可写.

chmod 644 ./my.cnf

问题2.

mysql 不允许使用root账号来启动MySQL服务

解决

强制使用root 用户启动MySQL服务 

mysqld --user=root start 

问题3.

首次使用临时密码 登录MySQL 当你想操作数据库时 或者查看 数据库  show databases; 会提示

 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

你必须使用alter user 语句 重置你的密码当你执行这个语句之前

解决

重新设置密码

alter user 'root'@'localhost' identified by 'root';

然后在进行其他操作 

猜你喜欢

转载自blog.csdn.net/a15835774652/article/details/116489961