博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
windows安装mysql
阅读量:4693 次
发布时间:2019-06-09

本文共 5973 字,大约阅读时间需要 19 分钟。

MySQL介绍

MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下公司。MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。

mysql是什么

mysql就是一个基于socket编写的C/S架构的软件客户端软件  mysql自带:如mysql命令,mysqldump命令等  python模块:如pymysql

数据库管理软件分类

分两大类:  关系型:如sqllite,db2,oracle,access,sql server,MySQL,注意:sql语句通用  非关系型:mongodb,redis,memcache可以简单的理解为:    关系型数据库需要有表结构    非关系型数据库是key-value存储的,没有表结构

下载

访问下载mysql5.6

下载后解压缩,看到如下目录

 

安装启动mysql

1.添加环境变量【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行,双击】 --> 【将MySQL的bin目录路径追加到变值值中,用 ; 分割】
2.初始化mysqld --initialize-insecure3.启动MySQL服务mysqld # 启动MySQL服务4.启动MySQL客户端并连接MySQL服务mysql -u root -p # 连接MySQL服务器

打开一个终端输出mysqld启动服务,另一个终端输入mysql访问mysql,出现界面mysql > 说明启动mysql成功

 

5.查看mysql服务

takslist |findstr mysql

 

 

将MySQL服务制作成windows服务

注意:--install前,必须用mysql启动命令的绝对路径# 制作MySQL的Windows服务,在终端执行此命令:mysqld --install# 移除MySQL的Windows服务,在终端执行此命令:mysqld --remove注册成服务之后,以后再启动和关闭MySQL服务时,仅需执行如下命令:# 启动MySQL服务net start mysql# 关闭MySQL服务net stop mysql

 用管理员cmd输入命令

 

 

杀掉mysql进程,启动服务

 

启动与停止mysql服务

 

 

登录设置密码

C:\Windows\system32>mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.41 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>mysql>mysql> select user(); # 查看用户+----------------+| user()         |+----------------+| ODBC@localhost |+----------------+1 row in set (0.00 sec)mysql> exitByeC:\Windows\system32>mysql -u root -p #使用root用户登录,默认密码为空Enter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.6.41 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> select user();+----------------+| user()         |+----------------+| root@localhost |+----------------+1 row in set (0.00 sec)mysql> exitByeC:\Windows\system32>mysqladmin -u root -p password "123" #修改密码123Enter password:Warning: Using a password on the command line interface can be insecure.C:\Windows\system32>mysql -u root -p  #用密码123登录数据库Enter password: ***Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.6.41 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> exitByeC:\Windows\system32>mysqladmin -u root -p123 password "456"  #修改密码为456Warning: Using a password on the command line interface can be insecure.C:\Windows\system32>mysql -uroot -p456 #用密码456登录数据库Warning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.6.41 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> select user()    -> ;+----------------+| user()         |+----------------+| root@localhost |+----------------+1 row in set (0.00 sec)

  

破解密码

#1 关闭mysql#2 在cmd中执行:mysqld --skip-grant-tables#3 在cmd中执行:mysql#4 执行如下sql:update mysql.user set authentication_string=password('') where user = 'root';flush privileges;#5 tskill mysqld #或taskkill -f /PID 进程号#6 重新启动mysql

 

 停止mysql服务,跳过授权方式启动

 

修改mysql服务器root密码

C:\Users\>mysql -uroot -p              #使用空密码登录Enter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.6.41 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> select user();+--------+| user() |+--------+| root@  |+--------+1 row in set (0.00 sec)mysql> update mysql.user set password=password("111") where user="root" and host="localhost"; #修改密码Query OK, 1 row affected (0.01 sec)Rows matched: 1  Changed: 1  Warnings: 0mysql> flush privileges;               #刷新权限Query OK, 0 rows affected (0.03 sec)mysql> exitBye

  

重启mysql服务器,使用新密码111登录

 

统一字符编码

强调:配置文件中的注释可以有中文,但是配置项中不能出现中文

#在mysql的解压目录下,新建my.ini,然后配置#1. 在执行mysqld命令时,下列配置会生效,即mysql服务启动时生效[mysqld];skip-grant-tablesport=3306character_set_server=utf8default-storage-engine=innodbinnodb_file_per_table=1#解压的目录basedir=C:\pythonStudy\mysql5.6#data目录datadir=C:\pythonStudy\mysql5.6\data\ #在mysqld --initialize时,就会将初始数据存入此处指定的目录,在初始化之后,启动mysql时,就会去这个目录里找数据#2. 针对客户端命令的全局配置,当mysql客户端命令执行时,下列配置生效[client]port=3306default-character-set=utf8user=rootpassword=111#3. 只针对mysql这个客户端的配置,2中的是全局配置,而此处的则是只针对mysql这个命令的局部配置[mysql];port=3306;default-character-set=utf8user=egonpassword=4573

 my.ini字符编码设置 

#1. 修改配置文件[mysqld]default-character-set=utf8 [client]default-character-set=utf8 [mysql]default-character-set=utf8#mysql5.5以上:修改方式有所改动[mysqld]character-set-server=utf8collation-server=utf8_general_ci[client]default-character-set=utf8[mysql]default-character-set=utf8#2. 重启服务#3. 查看修改结果:\sshow variables like '%char%'

 

 

  

 

 

windows mysql默认安装字符

 

  修改mysql字符后,重启查看新设置的utf-8字符

 

 

 

转载于:https://www.cnblogs.com/xiao-apple36/p/9521195.html

你可能感兴趣的文章