zoukankan      html  css  js  c++  java
  • Mysql 初始化配置,使用总结

    1. 添加,授权用户
    mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; //创建用户 mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' -> WITH GRANT OPTION; //授权用户

    mysql> SHOW GRANTS FOR 'admin'@'localhost';                        //查看用户权限 granted

    mysql> SHOW CREATE USER 'admin'@'localhost'G                      //查看用户权限 ungranted

    mysql> CREATE USER 'custom'@'localhost' IDENTIFIED BY 'obscure';
    mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
        ->     ON bankaccount.*
        ->     TO 'custom'@'localhost';                                //部分授权
    mysql> CREATE USER 'custom'@'host47.example.com' IDENTIFIED BY 'obscure';
    mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
        ->     ON expenses.*
        ->     TO 'custom'@'host47.example.com';
    mysql> CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'obscure';
    mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
        ->     ON customer.*
        ->     TO 'custom'@'%.example.com';


    • The first account can access the bankaccount database, but only from the local host.

    • The second account can access the expenses database, but only from the host host47.example.com.

    • The third account can access the customer database, from any host in the example.com domain. This account has access from all machines in the domain due to use of the %” wildcard character in the host part of the account name.

     
    2. 修改密码

    root@localhost[(none)]> set password for 'fred'@'localhost'=password('passwd');  

    Query OK, 0 rows affected (0.00 sec)  

    1. root@localhost[(none)]> flush privileges;  
    2. Query OK, 0 rows affected (0.00 sec)  
     
     

    3. 使用mysqldump导出固定条件的数据库,使用source导入数据库

    我们来看几个常用用例:
    (1)导出整个数据库

    mysqldump -u 用户名 -p 数据库名 > 导出的文件名 
    mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql

    (2)导出一个表

    mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
    mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql

    (3)导出一个数据库结构

    mysqldump -u wcnc -p -d --add-drop-table smgp_apps_wcnc >d:wcnc_db.sql
    #-d 不导出数据只导出结构 --add-drop-table 在每个create语句之前增加一个drop table 

    (4)导入数据库,常用source 命令

    #进入mysql数据库控制台,
    mysql -u root -p 
    mysql>use 数据库
    mysql>set names utf8; (先确认编码,如果不设置可能会出现乱码,注意不是UTF-8)  #然后使用source命令,后面参数为脚本文件(如这里用到的.sql) mysql>source d:wcnc_db.sql
     
    4. 删除数据库
    drop database 数据库名




  • 相关阅读:
    A program file was not specified in the launch configuration.
    Effective C++条款38: 决不要重新定义继承而来的缺省参数值
    进程控制块
    Effective C++条款37: 决不要重新定义继承而来的非虚函数
    Effective C++条款42: 明智地使用私有继承
    迭代的是人,递归的是神(第一篇——递归调用的分析)
    Effective C++条款36: 区分接口继承和实现继承
    进程上下文
    进程的层次结构 ——进程组捕捉信号
    SQL语句的并集UNION,交集JOIN(内连接,外连接),交叉连接(CROSS JOIN笛卡尔积),差集(NOT IN)
  • 原文地址:https://www.cnblogs.com/Raymond-Yang/p/5387528.html
Copyright © 2011-2022 走看看