• mysql-1


    接触mysql已经一年多了,但是平时很少用到,仅限于安装部署,最近在学习运维开发,需要用到数据库,于是买了一本mysql必知必会,给自己一个两个星期的时间,学完这本书,

    写这一系列的博客,就是记录学习过程,走过的坑,迈过的坎,做一个记录。

    这是这本书的链接

    http://www.forta.com/books/0672327120/

    为了学习各个例子,需要一组填充了数据的表,所需要获得和运行的一切东西在这个链接都可以找到。此网页包含了两个可以下载的SQL脚本,

    create.sql包含创建的6个数据库表

    populate.sql包含用来填充这些表的INSERT语句

    工欲善其事,必先利其器,先安装mysql并创建用户授权。

    windows安装mysql

    mysql下载地址  http://dev.mysql.com/downloads/mysql/

    下载好之后,一直点击下一步就 安装完毕,没有什么难度。配置mysql环境变量重点说一下

    win7环境下:

    右击 计算机--->选择高级系统设置--->选择环境变量--->Administrator的用户量,找到Path --->点击编辑 --->在变量值的最末尾添加安装mysql的路径,这是我安装的路径(C:Program FilesMySQLMySQL Server 5.7in;)

    打开powershell,直接输入mysql 就成功登录了。

    配置密码:

    mysqladmin -uroot password 123456

    创建用户并授权

    [root@VM_27_98_centos ~]# mysql -uroot -p           
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 4
    Server version: 5.1.73 Source distribution
    
    Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    

    创建用户并授权 mysql> grant all privileges on *.* to whh@'%' identified by '123456'; Query OK, 0 rows affected (0.00 sec)

    grant

    all privileges

    on *.*

    to username

    @'%'

    Identifified by ‘password’

    授权命令

    对应权限

    目标:库和表

    用户名和客户端主机

    用户密码

    查看用户具体授权
    mysql> show grants for whh@'%'; +------------------------------------------+ | Grants for whh@% | +------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'whh'@'%' | +------------------------------------------+ 1 row in set (0.00 sec)


    取消授权

    mysql> revoke all on *.* from whh@'%';

    Query OK, 0 rows affected (0.00 sec)

    mysql> show grants for 'whh'@'%' ;
    +---------------------------------+
    | Grants for whh@% |
    +---------------------------------+
    | GRANT USAGE ON *.* TO 'whh'@'%' |
    +---------------------------------+
    1 row in set (0.00 sec)

    删除用户

    mysql> drop user 'whh'@'%';
    Query OK, 0 rows affected (0.01 sec)

    导入本书的表和数据

    mysql> use study;
    mysql> source C:MySQLcreate.sql
    mysql> source C:MySQLpopulate.sql

    到此基础配置和准备工作已经做好了,明天开始正式学习mysql

  • 相关阅读:
    文件操作和网络通信
    h4和c2的简单内容
    Node介绍
    终端命令和环境变量
    C#连接MySQL数据库方法
    多点触控
    wp7全景控件
    Silverlight数据绑定转换示例
    Windows Phone 7两个页面动画跳转
    使用.NET操作SQLLITE
  • 原文地址:https://www.cnblogs.com/kafeikele/p/6074299.html
Copyright © 2020-2023  润新知