几个常用的mysql命令

1、远程导出数据:

mysqldump -h 192.168.49.36 -u myuser -p test>test.sql

2、为没有密码的root用户新增密码:

以root用户登录:

mysql -u root -p

update mysql.user set password=PASSWORD('root') where User='root';

flush privileges;

\q

3、向mysql导入数据库:

新建一个数据库

mysql>create database testdb;

use testdb;

mysql>source test.sql;

4、新建用户

create user 'myuser'@'%' identified by 'mypassword';

这样就创建了一个名为myuser密码为mypassword的可以从任意机器访问的用户;

赋权:

grant all privileges on *.* to 'myuser'@'%' identified by 'mypassword' with grant option;

flush privileges;

原文地址:https://www.cnblogs.com/yeahgis/p/2395505.html