参考:
http://mysqlserverteam.com/the-mysql-sys-schema-in-mysql-5-7-7/
分别在Windows下和Linux下重置了MYSQL的root的密码:
此外还有的新特性:
1.perfomence_schema与infomation_schema合并,因此,以后禁止锁定perfomence_schema对性能的监测。
2.密码可以设置过期时间
3.账号可以锁定。
4.多源复制,多线程复制
5.新增对计算列,JSON等支持
在windows下
1:进入cmd,停止mysql服务:
net stop mysql
到mysql的安装路径启动mysql,在bin目录下使用mysqld.exe启动,
2:执行如下命令:(窗口会一直停止)
mysqld --skip-grant-tables
3:然后另外打开一个命入令行窗口,执行mysql(或者直接进入Mysql Command Line Cilent),此时无需输入密码即可进入。
>use mysql
>update user set password=password("新密码") where user="root";
>flush privileges;
>exit
4:使用任务管理器,找到mysqld-nt的进程,结束进程!
在重新启动mysql-nt服务,就可以用新密码登录了。
在linux下
如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。
启动 MySQL :bin/safe_mysqld --skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是
>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges
>quit
重新杀 MySQL ,用正常方法启动 MySQL 。
Mysql Installer&Linux常用配置
①windows平台上通过安装mysql installer安装时,需要注意,Connector,Notifier,Commity三个组建可选可不选,建议安装时不要勾选。
②windows平台上如果通过mysql installer安装,需要注意的是mysql需要初始化
假定安装在D:\mysql\mysql-5.7.13-winx64目录,那么我们需要新建my.ini 在此目录下,然后输入如下配置
# 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]
port=3306
#server_id = 2
#skip-locking
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
innodb_data_home_dir="D:\mysql\mysql-5.7.13-winx64/data/"
innodb_flush_log_at_trx_commit =1
innodb_log_buffer_size=128M
innodb_buffer_pool_size=128M
innodb_log_file_size=10M
innodb_thread_concurrency=16
innodb-autoextend-increment=1000
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
max_allowed_packet = 32M
explicit_defaults_for_timestamp=true
sql-mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
skip-grant-tables #初次登录mysql,可能会遇到拒绝访问问题,因此,使用该配置跳过密码验证
③配置环境变量
需要将 D:\mysql\mysql-5.7.13-winx64\bin;加入到系统环境变量path中。
④将mysql注册为windows系统服务
cmd命令行进入到D:\mysql\mysql-5.7.13-winx64\bin下,执行如下命令,将服务注册到系统
mysqld install MySQL --defaults-file="D:\mysql\mysql-5.7.13-winx64\my.ini"
如果配置需要更改,可以通过如下命令移除注册信息后重新注册
mysqld remove
⑤初始化data目录
mysqld --initialize
此步骤非常重要,未初始化,可能会导致mysql服务无法启动(坑一)
⑥.打开系统服务管理
可以看到mysql系统服务
启动mysql命令为: net start mysql
关闭mysql命令为:net stop mysql
重启mysql命令为:net stop mysql & net mysql start
⑦、修改root密码,防止无法登录
(可能遇到的问题Access denied for user 'root'@'localhost' (using password: NO/YES))
命令行执行:
mysql –uroot #跳过密码验证,与skip-grant-tables对应
mysql>show databases;
mysql>use mysql;
mysql> update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> QUIT
注意:
如下命令是新版本的mysql(5.5+)中修改用户名的方式
update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
旧版本命令是
UPDATE user SET Password=PASSWORD(
'newpassword'
) where USER=
'root'
⑧、远程登陆配置
允许root用户在任何地方进行远程登录,并具有所有库任何操作权限,具体操作如下:
1)在本机先使用root用户登录mysql:
命令行执行:mysql -u root -p
输入密码(之前步骤设置的密码):12345
2)进行授权操作:
>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345' WITH GRANT OPTION;
>FLUSH PRIVILEGES;
>quit
注意:本步骤的配置依然是在skip-grant-tables进行的,这样不是用密码仍然可以登录,但是安全性问题不可避免,因此,我们有必要去掉skip-grant-tables或者注释掉skip-grant-tables配置后,在进行本步骤⑧的操作。
当我们去掉skip-grant-tables配置,我们在mysql命令行中执行命令,我们可能遇到如下问题
mysql error You must reset your password using ALTER USER statement before executing this statement.
遇到这种错误,解决办法是
#mysql -h 127.0.0.1 -p 3306 -u root -p 12345
>SET PASSWORD=PASSWORD('12345');
>ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
>flush privileges;
注意,上面从第一句开始也可能出错,问题是由于MySQL5.7有了密码强度验证错略。
Your password does not satisfy the current policy requirements
解决办法如下:
找到所有密码策略,进行修改具体请参考 :mysql5.7设置简单密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements