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密码忘记
- 方法一
- 关闭MySQL服务,修改MySQL初始文件
- 在MYSQLroot etc/my.cnf 最后一行加上 skip-grant-tables 如果没有这个文件 参考上边的自己建立
- 启动MYSQL服务
- 通过客户端 登陆
//空密码直接进入
mysql -uroot -p;
//重置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
//这步最重要.要刷新用户后才可以连接
List item
mysql>FLUSH PRIVILEGES;
- 方法二
- 关闭mysql服务
- 命令重启服务
启动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;