mysql管理员_mysql管理员操作

mysql查帮助手册的技巧:help 你的命令;比如 help create;

>>显示mysql中用户:select host,user from mysql.user;

>>>创建用户:mysql> create user 'zhangpeng'@'%' identified by 'oradt!@#&*(';

>>授权某个用户拥有某个数据库的任何权限:

GRANT ALL PRIVILEGES ON stock_info.* TO 'test'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

创建数据库: mysql> create database stock_info default charset utf8 collate utf8_general_ci;

>>> 查看用户权限(显示用户权限): show grants from  用户名;  //show grants; 显示当前自己的权限

修改用户密码-> 首先进入命令行下, 以root用户登录,命令:mysql -uroot -p 回车 输入密码再回车;

USER mysql;

UPADTE user set  password=password('root') where user='root';

mysql> FLUSH PRIVILEGES;//记得要这句话

>>> mysql优化表(回收表占用的闲置数据库空间),代码如何:

REPAIR TABLE `table_name` 修复表OPTIMIZE TABLE `table_name` 优化表

1.备份表结构(加上-d只备份表结构,不加此参数表结构、数据都备份):

C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqldump -hlocalhost -P3308 -uroot

-p -d stock_info>F:/stock_info.sql

Enter password: ******

备份单个表的数据(表必须不存在):

create table st_pool_bak as SELECT  id,code FROM `st_pool` ;

mysql 查看数据库中所有表的记录数(总记录数)

use information_schema;

select table_name,table_rows from tables

where TABLE_SCHEMA = 'imora_scan'

order by table_rows desc;

MySQL LIMIT分页优化: SELECT * FROM `api_statistic` as apis

INNER JOIN (select id from api_statistic as ap2   limit 1410000,10 ) as c using(id);

Mysql查询表字段(列名): select COLUMN_NAME from information_schema.COLUMNS where table_name = 'biz_employee_cards';

把字段合并成一条记录返回: select GROUP_CONCAT(COLUMN_NAME) from information_schema.COLUMNS where table_name = 'biz_employee_cards';

select COLUMN_NAME from information_schema.COLUMNS where table_name = 'your_table_name' and table_schema = 'your_db_name';

GROUP_CONCAT ( url SEPARATOR " @ " )

开启mysql远程访问端口: iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

service iptables save

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值