标签:访问 where root密码 mysql 用户名 dmi span select mysq
创建密码:
mysqladmin -u root -p password newpassword
或
MariaDB [(none)]> use mysql MariaDB [mysql]> update user set password=password("123456")where user=‘root‘; Query OK, 0 rows affected (0.00 sec) Rows matched: 4 Changed: 0 Warnings: 0 MariaDB [mysql]> flush privileges; Query OK, 0 rows affected (0.00 sec)
开启远程服务:
查看user表:可以发现表中没有开启远程的服务 % root
mysql> use mysql; Database changed mysql> select host,user,password from user; +--------------+------+-------------------------------------------+ | host | user | password | +--------------+------+-------------------------------------------+ | localhost | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E | | 127.0.0.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E | +--------------+------+-------------------------------------------+ 2 rows in set (0.00 sec)
实现远程连接(授权法):
将host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器,建议在开发时设为%。
update user set host = ’%’ where user = ’root’; 将权限改为ALL PRIVILEGES
mysql> use mysql; Database changed mysql> grant all privileges on *.* to root@‘%‘ identified by "password"; Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec) mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| 127.0.0.1 | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| ::1 | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| localhost | | |
| % | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+-----------+------+-------------------------------------------+
5 rows in set (0.00 sec)
这样机器就可以以用户名root密码远程访问该机器上的MySql.
标签:访问 where root密码 mysql 用户名 dmi span select mysq
原文地址:https://www.cnblogs.com/kaneyang/p/9116057.html