mysql的坑

mysql 下载

点击直接下载

mysql 安装完后Navicat无法连接

这个是因为密码加密方式要改

PATH="$PATH":/usr/local/mysql/bin //设置环境变量
mysql -u root -p;//登陆MYSQL
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql>FLUSH PRIVILEGES; //这步最重要.要刷新用户后才可以连接

mysql8 添加远程用户

先创建一个远程用户

create user 'root'@'%' identified by '123456';

再进行授权,必须有远程用户视图才有用

grant all privileges on *.* to 'root'@'%' with grant option;

用户刷新,才会有效果

flush privileges;

如何在mac中修改mysql的sql_mode

针对mac端,并且没有my-default.cnf的用户

修改完后必须重启mysql

我们要在 usr/local/mysql/ 新建 etc/my.cnf , 如果这个文件存在那就直接修改

$ cd /etc
$ sudo vim my.cnf

my.cnf文件如下

# 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

[client]
default-character-set=utf8

[mysqld]
log-error=/usr/local/mysql/data/mysqld.log
# skip-grant-tables
# 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 = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

有关查看的命令

PATH="$PATH":/usr/local/mysql/bin //设置环境变量
mysql -u root -p;//登陆MYSQL
select @@sql_mode; //查看sql mode


这个是更改前的
# sql_mode=TRADITIONAL, ONLY_FULL_GROUP_BY ,NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER  
# Be careful changing this afterwards

mysql root被锁 及ROOT密码忘记

  1. 方法一
  1. 关闭MySQL服务,修改MySQL初始文件
  2. 在MYSQLroot etc/my.cnf 最后一行加上 skip-grant-tables 如果没有这个文件 参考上边的自己建立
  3. 启动MYSQL服务
  4. 通过客户端 登陆

//空密码直接进入
mysql -uroot -p;
//重置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
//这步最重要.要刷新用户后才可以连接

 List item

mysql>FLUSH PRIVILEGES; 

  1. 方法二
  1. 关闭mysql服务
  2. 命令重启服务
启动mysql服务
mysqld -nt --skip-grant-tables
进入mysql切换到用户表
use mysql;
//重置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql> flush privileges;
mysql> exit;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值