mysql安装

MYSQL下载

https://www.mysql.com/downloads/

->mysql community

->mysql community server download ->mysql community server 5.7

 

Mysql安装文档2019.05.06

1、 运行G:\工作\mysql5.7.26\mysql-5.7.26-winx64.msi,如果文件是ZIP则直接解压到安装目录

2、 .配置环境变量(目的是为了避免在CMD窗口下操作时反复切换路径)在Path下添加C:\Program Files\MySQL\MySQL Server 5.7\bin

3.编写配置文件

我们发现解压后的目录并没有my.ini(或my-default.ini)文件,没关系可以自行创建。在安装根目录下添加 my.ini,比如我这里是:C:\Program Files\MySQL\MySQL Server 5.7\\my-default.ini,写入基本配置:

[mysqld]

# 设置3306端口

port=3306

# 设置mysql的安装目录

basedir=C:\Program Files\MySQL\MySQL Server 5.7\

# 设置mysql数据库的数据的存放目录

datadir=C:\Program Files\MySQL\MySQL Server 5.7\data

# 允许最大连接数

max_connections=200

# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统

max_connect_errors=10

# 服务端使用的字符集默认为UTF8

character-set-server=utf8

# 创建新表时将使用的默认存储引擎

default-storage-engine=INNODB

# 默认使用“mysql_native_password”插件认证

default_authentication_plugin=mysql_native_password

[mysql]

# 设置mysql客户端默认字符集

default-character-set=utf8

[client]

# 设置mysql客户端连接服务端时默认使用的端口

port=3306

default-character-set=utf8

 

4、MYSQL 执行安装

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld install

Service successfully installed.

 

 


5、MYSQL初始化

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize --console

2019-05-07T01:03:58.089955Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-05-07T01:03:59.425915Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-05-07T01:03:59.858905Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2019-05-07T01:04:00.012429Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ff60d9a5-7063-11e9-93dc-7427eac27e63.

2019-05-07T01:04:00.067655Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2019-05-07T01:04:00.232744Z 1 [Note] A temporary password is generated for root@localhost: g/)pkWZzM32N

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>

 

 

6、MYSQL 启动服务

C:\Program Files\MySQL\MySQL Server 5.7\bin>net start mysql

MySQL 服务正在启动 .

MySQL 服务已经启动成功。

 

7、修改初始化密码:

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p

Enter password: ************

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.26

Copyright (c) 2000, 2019, 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> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

 

8、利用初始化密码登录

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p

Enter password: ****

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.26 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2019, 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>

 

 

修改Mysql 数据库默认密码方法二

bin目录下的工具mysqladmin 

格式:mysqladmin -u用户名 -p旧密码 password 新密码 
例子:mysqladmin -uroot -p123456 password 123 

 

工具连接本地的mysql数据库

 

 

 

 

 

posted @ 2019-07-02 23:01  ravel  阅读(217)  评论(0编辑  收藏  举报