环境:mysql5.7

连接本地数据库

[sql]
mysql -u root -p
[/sql]

连接远程数据库

[sql]
mysql -h 110.110.110.110 -u root -p
[/sql]

创建数据库demo:

[sql]
CREATE database `demo`;
[/sql]

创建一个账号work

[sql]
CREATE USER ‘work’@’127.0.0.1’ IDENTIFIED BY ‘123456’;
[/sql]

给work账号赋予demo数据库相关权限

[sql]
grant alter,create,drop,delete,select,update,insert on demo.* to ‘work’@’127.0.0.1’ identified by ‘123456’;
grant ALL PRIVILEGES on demo.* to ‘work’@’127.0.0.1’ identified by ‘123456’;
FLUSH PRIVILEGES;
[/sql]

退出mysql

[sql]
exit
[/sql]

显示数据文件的存放位置

[sql]
show global variables like “%datadir%”;
[/sql]

命令行执行sql文件,注意路径不能有中文,最好是英数字

[sql]
source C:\test.sql
[/sql]