zoukankan      html  css  js  c++  java
  • mysql (5.7版本)---的配置

    1、去到官方网站下载

        https://dev.mysql.com/downloads/installer/

        或者直接下载  --》  https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-winx64.zip

             

       

    一、配置MySQL数据库

          

             

     二、安装服务

                进入管理员的DOS 命令界面

        1、运行cmd(管理员版本,否则没有权限),如下图

      

        

           

        2、对于新版mysql5.7没有了data目录,我们需要运行命令创建

            --initialize-insecure --user=mysql

          

          

         

        

        3、运行命令mysqld –install安装服务,如下图:

            

            

            

          如果不需要mysql里,只需要运行mysqld –remove即可移除,如下图

              

        

        3、运行net start mysql 启动服务,如下图

            

            

      

          如需要配置是否开机启动mysql可以在windows 服务  里面配置。

     

    三、客户端测试

         1、   mysql –uroot –p 如下图

             

        

        

    四、修改用户名密码

          1、运行命令

                use mysql;

                UPDATE user SET authentication_string=password('123456') where user='root';

                FLUSH PRIVILEGES;

            如下图:

            

            

        

         2、重新登陆,运行命令mysql -uroot -p123456

            

            

        

        

    五、配置编码为UTF-8

    1、查看默认编码

           

        

    2、在mysql5.7的根目录下,新建my.ini文件,(5.7后没了这文件,自己新建),如下图:

          

        

        Mysql服务程序启动时会自动读取my.ini获得各项配置参数,包括编码

          

      

    2、编辑my.ini

         在[mysqld]节点下,配置服务端编码,添加2项内容

            character_set_server=utf8

           [mysql]节点的,这个是配置客户端信息的

          我们也添加[mysql]节点,并配置编码UTF8

        [mysql]

        default-character-set=utf8

         合起来如下图:

          

       

    六、测试查询

    1、修改了配置文件必须先重启服务

          

      

      

    2、正常使用root用户登陆

          

        

    3、运行命令show variables like "%character%"查看系统字符集变量,如下图:

            

         

     4、在data  目录下新建一个文件夹

           create database test1;

          

      

       5、 切换到 test1

                use test1;

           

      

              

     

         成功后

            

      

     

     

      

      

           

          

    ----建库
    create database test2;

    ---建表
    create table student(sno varchar(20),name varchar(20),birt date);

    -----查询语句

    select * from student;

    select name,birt from student;

    select name,birt from student
    where name='小明';

    select name,birt from student
    where ='小明'or name='小刚';

    -----插入语句

    insert into student(sno ,name) values('1','小明');

    insert into student values('2','小王','1998-04-02');

    insert into student values('3','小点','1998-04-02'),
    ('3','小是','1998-02-02'),
    ('3','小的','1998-01-02'),
    ('3','小号','1998-03-02')
    ;

        

    select sno,name from student
    where namein ('小明','小刚');
     
    select sno,name from student
    where name not in ('小明','小刚');
     
     
    删除前 先查询一下 避免删除错误
     
    查询
    select * from student where sno='1';
     
    删除
    delete from student where sno='1';
     
    改‘
    select * from student where sno='4';
    update student set birt='2017/06/05' where sno='4';
     
    update student set birt='2017/06/05' , sno='6' where sno='4';
     
     
     
     
    统计
    SELECT c_name,MAX(grade) FROM score GROUP BY c_name;
    SELECT name, id FROM student GROUP BY id;
     
     

      练习题指引     

    http://blog.sina.com.cn/s/blog_767d65530101861c.html 

            

        

          

  • 相关阅读:
    重构之重新组织函数(Split Temporary Variable)
    HammperSpoon 不能 Focus Google Chrome 的问题
    如何让 vim 可以在命令行执行命令并且附加参数
    This bison version is not supported for regeneration of the Zend/PHP parsers
    php cURL library is not loaded
    aws linuxbrew GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2
    gen-cpp/.deps/ChildService.Plo: No such file or directory
    快速解码base64和utf-8的ASCII编码和URL解码
    英文版firefox显示中文字体丑的问题
    linux find 反转 查找没有被找到的结果
  • 原文地址:https://www.cnblogs.com/LWMLWM/p/6922740.html
Copyright © 2011-2022 走看看