1. 进入mysql黑屏下,Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 62 Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>2.输入命令 source c:\database.sql; (source后面接的就是你的数据库(.sql文件)的地址)
Your MySQL connection id is 62
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>2.输入命令 source c:\database.sql; (source后面接的就是你的数据库(.sql文件)的地址)
他会提示你密码:
如果有密码就输入密码
无密码就直接回车
如果你已经存在呢数据库
就在命令输入:>use 数据库名
>set names 'utf8'
>source d:/dd.sql
在导入sql的时候一定要保证编码格式正确
我一搬都用命令行导出导入数据,这样不会出错,但是如果是利用工具导出,一般都会因为单引号,或者是双引号,或者是非法字符而导致导入导出不成功,因此强烈建议导入数据,导出数据均用命令行导。
在弹出的窗口下输入mysql -u 用户名 -p 数据库用户名 < 数据库名.sql (要在当前目录下操作)如:mysql -u root -p userDb < c:\user.sql 按回车键后输数据库的密码
create database userDb;Windows下:
点 开始->运行-> cmd
在弹出的窗口下输入
mysql -u 用户名 -p 数据库名称 < 数据库名.sql (指定sql文件存入的路径)
如:mysql -u root -p userDb < c:\user.sql 按回车键后输入数据库的密码