win11 mysql5.6.51安装登录卸载、及账号密码创建修改
一、卸载原先安装的mysql
D:\soft\mysql-8.0.29\bin>mysqld --remove
Service successfully removed.
D:\soft\mysql-8.0.29\bin>
注意:退出文件夹后才能删除mysql-8.0.29文件夹
二、下载mysql5.6.51
三、解压和简化
1.解压
2.简化
1.删除bin data share 之外的文件夹
2.删除bin目录下mysql.exe mysqld.exe 之外的文件
.pdb文件是c语言编译的临时文件,没什么用
这样mysql就变得很小了
四.安装
D:\>cd soft
D:\soft>cd mysql-5.6.51
D:\soft\mysql-5.6.51>cd bin
D:\soft\mysql-5.6.51\bin>mysqld install
Service successfully installed.
D:\soft\mysql-5.6.51\bin>
五.登录、查询信息、修改密码
1.登录
## 启动服务
D:\soft\mysql-5.6.51\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
## 账号登录
D:\soft\mysql-5.6.51\bin>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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>
2.查询信息
mysql> select @@hostname,@@port,@@version,@@basedir,@@datadir;
+------------+--------+-----------+-----------------------+----------------------------+
| @@hostname | @@port | @@version | @@basedir | @@datadir |
+------------+--------+-----------+-----------------------+----------------------------+
| summer | 3306 | 5.6.51 | D:\soft\mysql-5.6.51\ | D:\soft\mysql-5.6.51\data\ |
+------------+--------+-----------+-----------------------+----------------------------+
1 row in set (0.00 sec)
mysql> select host,user,password,plugin from mysql.user;
+-----------+------+----------+-----------------------+
| host | user | password | plugin |
+-----------+------+----------+-----------------------+
| localhost | root | | mysql_native_password |
| 127.0.0.1 | root | | mysql_native_password |
| ::1 | root | | mysql_native_password |
| localhost | | | mysql_native_password |
+-----------+------+----------+-----------------------+
4 rows in set (0.01 sec)
## 密码为空
3.修改密码
mysql> set password = password('root'); #修改当前账号密码
mysql> set password = password('root');
Query OK, 0 rows affected (0.01 sec)
mysql> select host,user,password,plugin from mysql.user;
+-----------+------+-------------------------------------------+-----------------------+
| host | user | password | plugin |
+-----------+------+-------------------------------------------+-----------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | mysql_native_password |
| 127.0.0.1 | root | | mysql_native_password |
| ::1 | root | | mysql_native_password |
| localhost | | | mysql_native_password |
+-----------+------+-------------------------------------------+-----------------------+
4 rows in set (0.00 sec)
4.创建账号并授权
## 使用GRANT语句创建名为aa的用户,主机名为localhost,密码为123。该用户对所有数据库的所有表都有SELECT权限。
GRANT SELECT ON*.* TO 'aa'@localhost IDENTIFIED BY '123';
## 其中,“*.*”表示所有数据库下的所有表。结果显示创建用户成功,且aa用户对所有表都有查询(SELECT)权限。
5.账号删除
# 删除账户及权限:
drop user 用户名@'%';
drop user 用户名@localhost;
mysql> select host,user,password,plugin from mysql.user;
+-----------+------+-------------------------------------------+-----------------------+
| host | user | password | plugin |
+-----------+------+-------------------------------------------+-----------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | mysql_native_password |
| 127.0.0.1 | root | | mysql_native_password |
| ::1 | root | | mysql_native_password |
| localhost | | | mysql_native_password |
| % | aa | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 | mysql_native_password |
+-----------+------+-------------------------------------------+-----------------------+
5 rows in set (0.00 sec)
mysql> drop user aa@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user,password,plugin from mysql.user;
+-----------+------+-------------------------------------------+-----------------------+
| host | user | password | plugin |
+-----------+------+-------------------------------------------+-----------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | mysql_native_password |
| 127.0.0.1 | root | | mysql_native_password |
| ::1 | root | | mysql_native_password |
| localhost | | | mysql_native_password |
+-----------+------+-------------------------------------------+-----------------------+
4 rows in set (0.00 sec)