一、安装
sudo apt install mysql-server
sudo service mysql restart
二、配置
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
在其中加入
skip-grant-table
重启MySQL并登录
service mysql restart
mysql -u root -p
现将密码设置为空,然后修改为自定义的密码
use mysql;
flush privileges;
UPDATE user SET authentication_string='' WHERE user='root';
flush privileges;
alter user 'root'@'localhost' identified with mysql_native_password by '1234';
quit;
删掉之前增加的那一行
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
重启MySQL并登录
service mysql restart
mysql -u root -p