发布网友 发布时间:2022-04-26 02:17
共2个回答
懂视网 时间:2022-05-02 22:30
C:UsersAdministrator>cd C:Program FilesMySQLin C:Program FilesMySQLin>mysqld --initialize --console 2018-04-28T15:57:17.087519Z 0 [System] [MY-013169] [Server] C:Program FilesMySQLinmysqld.exe (mysqld 8.0.11) initializing of server in progress as process 4984 2018-04-28T15:57:24.859249Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rI5rvf5x5G,E 2018-04-28T15:57:27.106660Z 0 [System] [MY-013170] [Server] C:Program FilesMySQLinmysqld.exe (mysqld 8.0.11) initializing of server has completed C:Program FilesMySQLin>
注意!执行输出结果里面有一段: [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rI5rvf5x5G,E 其中root@localhost:后面的“rI5rvf5x5G,E”就是初始密码(不含首位空格)。在没有更改密码前,需要记住这个密码,后续登录需要用到。
要是你手贱,关快了,或者没记住,那也没事,删掉初始化的 datadir 目录,再执行一遍初始化命令,又会重新生成的。当然,也可以使用安全工具,强制改密码,用什么方法,自己随意。
参考:https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization-mysqld.html
3.2 安装服务
在MySQL安装目录的 bin 目录下执行命令:
mysqld --install [服务名]
后面的服务名可以不写,默认的名字为 mysql。当然,如果你的电脑上需要安装多个MySQL服务,就可以用不同的名字区分了,比如 mysql5 和 mysql8。
安装完成之后,就可以通过命令net start mysql启动MySQL的服务了。通过命令net stop mysql停止服务。通过命令sc delete MySQL/mysqld -remove卸载 MySQL 服务
4、更改密码
在MySQL安装目录的 bin 目录下执行命令:
mysql -u root -p
这时候会提示输入密码,记住了上面第3.1步安装时的密码,填入即可登录成功,进入MySQL命令模式。
在MySQL中执行命令:
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘新密码‘;
修改密码,注意命令尾的;一定要有,这是mysql的语法
到此,安装部署就完成了。官方说测试速度MySQL8比5快两倍。
可以用 命令查看一下默认安装的数据库:
show databases;
use mysql;
show tables;
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql>
看到默认初始化了mysql数据库,其中user表里面存储MySQL用户信息。我们可以看一下默认MySQL用户:
select user,host,authentication_string from mysql.user;
mysql> select user,host,authentication_string from mysql.user; +------------------+-----------+-------------------------------------------+ | user | host | authentication_string | +------------------+-----------+-------------------------------------------+ | mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | root | localhost | *27C237A977F4F44D3F551F1A673BE14DFD232961 | +------------------+-----------+-------------------------------------------+ 4 rows in set (0.00 sec) mysql>
管理员root的host是localhost,代表仅限localhost登录访问。如果要允许开放其他ip登录,则需要添加新的host。如果要允许所有ip访问,可以直接修改成“%”
创建用户:
CREATE USER ‘xxh‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘xxh123!@#‘;
#(需要注意:mysql8.0加密方式修改了)
#检查用户
select user, host, plugin, authentication_string from userG;
授权远程数据库
#授权所有权限
GRANT ALL PRIVILEGES ON *.* TO ‘xxh‘@‘%‘;
#授权基本的查询修改权限,按需求设置
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON *.* TO ‘xxh‘@‘%‘;
查看用户权限
show grants for ‘xxh‘@‘%‘;
示例:
mysql> use mysql; Database changed mysql> CREATE USER ‘xxh‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘xxh123!@#‘; #创建用户(注意:mysql8.0加密方式修改了) Query OK, 0 rows affected (0.07 sec)
mysql>
查看密码加密方式:
mysql> select user, host, plugin, authentication_string from user; +------------------+-----------+-----------------------+-------------------------------------------+ | user | host | plugin | authentication_string | +------------------+-----------+-----------------------+-------------------------------------------+ | xxh | % | mysql_native_password | *70FD6FB4F675E08FF785A754755B5EBA6DA62851 | | mysql.infoschema | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | mysql.session | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | mysql.sys | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | root | localhost | mysql_native_password | *27C237A977F4F44D3F551F1A673BE14DFD232961 | +------------------+-----------+-----------------------+-------------------------------------------+ 5 rows in set (0.00 sec) mysql>
另外,如果需要新增账户,或者本机以外的其他人访问MySQL则还需要设置内置账户的host,具体可以参考:MySQL创建用户与授权
参考自:http://www.cnblogs.com/xiongzaiqiren/p/8970203.html
Mysql8安装与配置
标签:设置 ref base sele sch ctrl 安装与配置 system .com
热心网友 时间:2022-05-02 19:38
你是重新配置,看上去是成功了,配置完成后,回到主界面,没有什么问题啊。你关闭主安装界面就可以了。