7.修改密码:
mysql> alter user 'root'@'localhost' identified by '123';
mysql> alter user session_user() identified by '123';
mysql> alter user user() identified by '123';
10.测试:
查看数据库:mysqlshow.exe -u root -p
查看mysql数据库中的表:mysqlshow.exe mysql -u root -p
执行一个sql语句:mysql -e "select user,host,plugin from mysql.user" mysql -u root -p
11.登录后,查看数据库 show databases;
12.再次初始化:
C:\Users\JeeStudy>mysqld --initialize --console
2020-03-27T02:58:20.717236Z 0 [System] [MY-013169] [Server] D:\MySQLDir\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progress as process 7492
2020-03-27T02:58:20.868250Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2020-03-27T02:58:20.868291Z 0 [ERROR] [MY-013236] [Server] The designated data directory D:\MySQLDir\data\ is unusable. You can remove all files that the server added to it.
2020-03-27T02:58:20.908326Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-03-27T02:58:20.949898Z 0 [System] [MY-010910] [Server] D:\MySQLDir\bin\mysqld.exe: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.
13.创建用户:create user 'angel'@localhost identified by '321';
14.数据库测试:mysql test -u root -p 123
15.查看字符集:
mysql> show variables like '%character%';
mysql> show charset;
2)修改mysql.user 中的Host,因为默认是localhost,只能本机连接(这也是一种安全策略) Host is not allowed to connect to this MySQL server。
解决方案:UPDATE `mysql`.`user` SET `Host`='%' WHERE `User`='root';(这里我们以root为例)
如果不重启服务器,还需要执行: flush privileges;