MYSQL的相关命令操作

一、忘记数据库密码时

(1)/etc/init.d/mysqld stop;         //停止数据库服务

(2)mysqld_safe --user=mysql --skip-grant-tables --skip-networking &;//登录会跳过验证

(3)mysql -u root   //root登录

(4)use mysql        //切换数据库

(5)update user set authentication_string=password('root') where user='root';

         //设置root用户的登录密码为root  (注意:这里的mysql版本是5.7,字段为                       authentication_string,如果字段报错,可以改为password)

(6)flush privileges;                         //立即生效

二、当本地的navicat访问对应linux服务器上的内容时,需要修改host字段为都可以访问,否则会出现Host 'xxx.xxx.xxx.xxx' is not allowed to connect this mysql的错误

(1)update user set host = '%' where user = 'root'; 

(2)flush privileges;                          //立即生效

三、linux环境下,执行mysql脚本

(1)mysql -u root -p                                   //登录mysql

(2)source /test/test.sql                           //执行sql脚本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值