apt-get install mysql-server -y
查看默认密码
cat /etc/mysql/debian.cnf
mysql -udebian-sys-maint -p密码
更改root密码
use mysql;
update user set authentication_string=PASSWORD("自定义密码") where user='root';
update user set plugin="mysql_native_password";
grant all privileges on *.* to root@'%' identified by "新密码";
flush privileges;
quit;
开启远程访问
nano /etc/mysql/mysql.conf.d/mysqld.cnf
#bind-address = 127.0.0.1
修改sql_mode
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
service mysql restart