mysql安装登陆退出

网上有很多mysql安装教程,这里不赘述。这里说一下安装好mysql后的一些设置。

1.安装完按顺序安装完mysql后启动mysql

systemctl start mysql

2.在 /var/log/mysql.log 查找root@localhost后面的密码。

3.登陆mysql

mysql -u root -p 

输入在日志文件里找到的密码登陆。

4.修改root用户密码(这一步是必须的,不然后面的操作数据库操作无法进行)

set password for 'root'@'localhost' = password('123456');

5.修改root用户远程登陆权限

 切换到mysql库

 use mysql;

查询root用户信息

select host,user from user where user='root';

修改root配置

update user set host = '%' where user = 'root' and host='localhost';

给用户授权

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

使配置生效

flush privileges;

到这里就可以进行远程登陆了

猜你喜欢

转载自www.cnblogs.com/e61005629/p/8977004.html