Mysql 8.0.22安装与初始化设置

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

解压缩路径:D:\ProgramData\mysql-8.0.22>

配置

在该文件夹下创建 my.ini 配置文件,编辑 my.ini 配置以下基本信息:

[client]
# 设置mysql客户端默认字符集
default-character-set=utf8
 
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\\ProgramData\\mysql-8.0.22
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=D:\\ProgramData\\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

启动MySQL 数据库:

当前路径下打开命令行

D:\ProgramData\mysql-8.0.22>cd bin

D:\ProgramData\mysql-8.0.22\bin>mysqld --initialize --console

D:\ProgramData\mysql-8.0.22\bin>mysqld.exe --initialize --console

D:\ProgramData\mysql-8.0.22\bin>mysqld.exe --initialize --console
2020-11-15T12:28:56.149397Z 0 [System] [MY-013169] [Server] D:\ProgramData\mysql-8.0.22\bin\mysqld.exe (mysqld 8.0.22) initializing of server in progress as process 7232
2020-11-15T12:28:56.150846Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-11-15T12:28:56.161092Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-11-15T12:29:01.781079Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-11-15T12:29:10.362567Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: mWi.b:Cg#0<q

D:\ProgramData\mysql-8.0.22\bin>mysqld install
Service successfully installed.

D:\ProgramData\mysql-8.0.22\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。

D:\ProgramData\mysql-8.0.22\bin>mysql -h localhost -u root -p mWi.b:Cg#0<q
系统找不到指定的文件。

不能直接输入密码????

D:\ProgramData\mysql-8.0.22\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22

更改密码:

mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> mysqladmin -u root -p mWi.b:Cg#0<q -password 123;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqladmin -u root -p mWi.b:Cg' at line 1

提示有语法错误,试了多次依然都是同样错误,原来8.0版本后改密码方法变了:

mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'Mypass@123';
Query OK, 0 rows affected (0.08 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.05 sec)

mysql> select host,user,authentication_string from mysql.user;
+-----------+------------------+------------------------------------------------------------------------+
| host      | user             | authentication_string                                                  |
+-----------+------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | $A$005$rql}p6     9^h7iP`Apo1rA0HJZQREpmwgP8inCCvfen5LsE0j1xU3UKId43 |
+-----------+------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

执行查询命令可以正常使用。

 

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值