赞
踩
mysql> SELECT `user`,`host`,`authentication_string`,`plugin` FROM mysql.user;
# 创建远程连接用户
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123456';
mysql> GRANT ALL ON maindataplus.* TO 'root'@'%';
mysql> flush privileges;
mysql> quit;
# 修改plugin模式
mysql> UPDATE mysql.user SET `plugin`='mysql_native_password' WHERE `user`='root';
mysql> flush privileges;
mysql> quit;
# 停止MySQL服务
windows系统:net stop mysql
Linux系统:service mysql stop
# 启动MySQL服务,加上--skip-grant-tables
以不需要登录密码的模式启动MySQL服务
Windows系统:
mysqld --skip-grant-tables
Linux系统:
/usr/sbin/mysqld --skip-grant-tables
新开一个命令行窗口,登录
mysql -uroot -p
# 回车,回车
# 修改root密码,方式一
mysql> use mysql;
mysql> update user set password=password(“123456”) where user=”root”;
mysql> flush privileges;
# 方式二(在mysql 5.7.9以后废弃了password字段和password()函数)
# 远程用户:'root'@'%',本地用户:'root'@'localhost',password换成你的密码
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
mysql> flush privileges;
mysql>quit;
重启mysql服务
windows系统:net restart mysql
Linux系统:service mysql restart
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。