开启远程访问
-- 本地登陆设置密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password1128';
flush privileges;
-- 查询用户
SELECT User,Host,authentication_string,plugin FROM user;
-- 开启远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Password11281128' WITH GRANT OPTION;
flush privileges;
mysql远程登录
命令:mysql -h 168.192.1.40 -P 3329 -u user -p
-h 表示主机
-P表示端口
-u表示用户
-p表示通过密码登录
mysql修改用户密码(三种方式)
下面的三个例子都是用户user的密码由654321改为123456
1、无需root密码,直接就可修改,建议用这种方式
SET PASSWORD FOR user=PASSWORD(‘123456’);
mysql> SET PASSWORD FOR user=PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
2、mysqladmin -u 用户名 -p 旧密码 password 新密码
mysqladmin -u user -p 654321 password 123456;
3、update user set password=password(‘123456’) where user=‘user’
mysql> use mysql;
Database changed
mysql> update user set password=password('123456') where user='user';
Query OK, 5 rows affected (0.00 sec) Rows matched: 5 Changed: 5 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)