MYSQL中常用的工具

1.mysql(客户端链接工具):
   -u :指定用户名

   -p:指定密码

   -h:指定服务器ip或者域名

   -P(大写):指定端口
  例子:mysql -u root -h 202.194.132.237 -P 3306 -p
     出现error: Host '202.194.132.237' is not allowed to connect to this MySQL server
  出现上述原因是因为:该用户没有权利进行远程访问,必须登陆数据库修改用户的权限.
  设置用户管理权限:
  grant 权限列表 [(字段列表)] on 数据库名.表名 to 用户名@域名或ip地址 [identified by '密码']   [with grant option]
  eg:
     1. grant all on *.* to wuxiaoxiao@'%' identified by '870805'
     2. grant select on java.* to wuxiaoxiao@'202.194.132.%' identified by '870805';
        grant update (name) on java.customer to wuxiaoxiao@'%';
     3. grant all on *.* to wuxiaoxiao@'localhost' identified by '870805';
  revoke 权限列表[(字段列表)] on 数据库.表名 from 用户名@域名或ip地址
     eg:revoke create,drop on java.* from wuxiaoxiao@'%';
        revoke grant option on java.* from wuxiaoxiao@localhost;
 登陆系统后:select current_user();查看当前链接的用户

  --default-character-set=gbk:设置客户端字符集选项
 eg:mysql -u root --defaule-character-set=gbk -p登陆后:
    等价与set names gbk;
    show  variables like  'chara%';查看客户端字符集
    
-e:执行sql语句并退出:
  msyql -u root -e "select * from user" 数据裤名字 -p

-E:将输出方式按照字段顺序竖着显示
-s:去掉mysql中的线条框显示
eg:mysql -u root -e "select * from user" BBS -p -E

-f:强行执行sql语句
-v:显示更多信息
--show-warnings:显示警告信息
eg:
在数据库test中有个表t2,只有一个字段id,是int型的
有以下几条插入语句(a.sql):
insert into t2 values(1);
insert into t2 values(2a);//错误
insert into t2 values(3);
不加上任何参数:
mysql -u root test(database-name) < a.sql
会出现错误,一条sql都没有执行
加上参数-f:
mysql -u root test(database-name) -f< a.sql
只有错误的那行没有执行
加上-v显示插入的详细信息:
mysql -u root test(database-name) -f -v< a.sql
加上--show-warnings
mysql -u root test(database-name) -f -v --show-warnings< a.sql

2.myisampack(MyISAM表压缩工具)
  eg:myisampack t3(t3.myd)

3.mysqladmin(MySQL管理工具)
  mysqladmin和mysql客户端登陆后执行的一些功能非常类似!
  可以执行的命令:

猜你喜欢

转载自www.cnblogs.com/jpfss/p/11490779.html