linux下安装完mysql后修改root密码

1.首先安装mysql

sudo apt-get install mysql-server

2.进入mysql

sudo mysql -uroot -p

由于没有密码,直接按回车就可以了。

3.设置密码

CREATE USER 'root'@'%' IDENTIFIED BY 'root';

UPDATE mysql.user SET authentication_string=PASSWORD('root'),plugin= 'mysql_native_password'  WHERE User = 'root'  AND  Host = 'localhost';

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;

FLUSH PRIVILEGES;

4.重启mysql

sudo service mysql restart

 

你可能感兴趣的:(技术漫谈)