1.登陆mysql:
mysql -u root mysql
2.开启远程连接,运行下面命令
UPDATE `mysql`.`user` SET `Host` = '%' WHERE `user`.`Host` = CAST( 0x6c6f63616c686f7374 AS BINARY ) AND `user`.`User` = CAST( 0x726f6f74 AS BINARY ) ;
3. 同时支持本地连接:
GRANT ALL PRIVILEGES ON *.* to 'root'@'localhost ' identified by '123456'; flush privileges; select * from user;
3.重启mysql
service mysqld restart
mysql远程连接命令
一、MySQL 连接本地数据库,用户名为“root”,密码“123”(注意:“-p”和“123” 之间不能有空格)
C:>mysql -h localhost -u root -p123
二、MySQL 连接远程数据库(192.168.0.201),端口“3306”,用户名为“root”,密码“123”
C:>mysql -h 192.168.0.201 -P 3306 -u root -p123