2009年2月9日星期一

mysql 相关

1. mysql数据库的迁移
方法1 : 导入导出
导出整个数据库:mysqldump -u -p <密码> > f:\数据库文件名称.dmp
-----<>表示是要输入的内容
导入整个数据库:
mysql -u root -p
>use 数据库名称
>source f:\数据库文件名称.dmp

方法2: 拷贝数据库文件的方法

对myisam 引擎的表可以使用直接拷贝 data目录下的文件的方式,
对于innodb类型的表则只能使用导出数据库的方法

2. 1130错误: root用户未授权从非localhost登录
ERROR 1130: Host 192.168.88.160 is not allowed to connect to this MySQL server

方法1 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称”%”

mysql -u root -p
mysql>use mysql;
mysql>update user set host = ‘%’ where user =’root’;
mysql>flush privileges;
mysql>select ‘host’,'user’ from user where user=’root’;

方法2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO‘myuser’@'%’IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON *.* TO‘myuser’@'192.168.1.3′IDENTIFIED BY ‘mypassword’ WITH
GRANT OPTION;

没有评论: