D:\Program Files\mysql\bin>mysqld --initialize --console2019-02-14T11:47:59.282979Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 13752
2019-02-14T11:47:59.284705Z 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.
2019-02-14T11:48:40.707445Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 7CwffH5<(lem
2019-02-14T11:49:02.894787Z 0 [System] [MY-013170] [Server] D:\Program Files\mysql\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed
注意!执行输出结果里面有一段: [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 7CwffH5<(lem,D 其中root@localhost:后面的“7CwffH5<(lem,D”就是初始密码(不含首位空格)。在没有更改密码前,需要记住这个密码,后续登录需要用到。 要是你手贱,关快了,或者没记住,那也没事,删掉初始化的 datadir 目录,再执行一遍初始化命令,又会重新生成的。当然,也可以使用安全工具,强制改密码,用什么方法,自己随意。
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
修改密码,注意命令尾的;一定要有,这是mysql的语法
二、账号配置与使用测试
2.1 数据库的创建、表单和字段配置
创建数据库:iodata
创建数据库表单:teacher ,user_info
创建数据库表单中的字段:user_id,user_pass,user_modified 等等
设置数据库表单中的主键。
CREATE DATABASE iodata;
use iodata;
/*show tables;
create table teacher
(
code varchar(20) primary key,
name varchar(20)
);*/
CREATE TABLE user_info
(
ID int NOT NULL AUTO_INCREMENT,/* 设置自动加的用户ID*/
user_id VARCHAR(200) NOT NULL,/*支持中英文200个字符的用户字符串*/
user_pass VARCHAR(200) NOT NULL,
user_create datetime(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
user_modified datetime(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
PRIMARY KEY (ID)/* 设置主键*/
);
2.2 配置数据库的用户访问账号密码,权限
use iodata;
CREATE USER 'porter'@'localhost' IDENTIFIED BY 'shuruniziji_mima';/* 创建用户 */
INSERT INTO iodata.user_info ( user_id, user_pass)
VALUES
( 'porter', '123');
grant all privileges on *.* to 'porter'@'%'; /* 放行用户的所有权限并允许远程网络连接 */