作者:朝阳又起风云 | 来源:互联网 | 2023-05-18 03:31
修改root密码mysqlUSEmysql;#切换到mysqlDBDatabasechangedmysqlSELECTUser,Password,HostFROMuser;#查看现
修改root密码 mysql USE mysql; #切换到 mysql DB Database changed mysql SELECT User, Password, Host FROM user; #查看现有用户,密码及允许连接的主机 ————————— | User | Password | Host | ————————— | root | | l
修改root密码
mysql> USE mysql; #切换到 mysql DB
Database changed
mysql> SELECT User, Password, Host FROM user; #查看现有用户,密码及允许连接的主机
+——+———-+———–+
| User | Password | Host |
+——+———-+———–+
| root | | localhost |
+——+———-+———–+
1 row in set (0.00 sec)
mysql> update user set password=PASSWORD(‘123456′) where user=’root’; #更新root的用户密码
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges; #刷新
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to [email protected]; [email protected]
Query OK, 0 rows affected (0.00 sec)
mysql> flush tables; #刷新
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> grant all on *.* to [email protected]%”; #%的ip都能远程访问root用户管理所有数据库密码的权限
Query OK, 0 rows affected (0.00 sec)
mysql> flush tables; #刷新
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> show grants for ‘root’@’%’;
+——————————————————————————————————————+
| Grants for root@% |
+——————————————————————————————————————+
| GRANT ALL PRIVILEGES ON *.* TO ‘root‘@’%’ IDENTIFIED BY PASSWORD ‘*ACAAE9E2C384B05A750FB998F83C9E13D5F716A5’ |
| GRANT ALL PRI本文来源gao@[email protected]@VILEGES ON `mstr`.* TO ‘root’@’%’ |
+——————————————————————————————————————+