Ubuntu20默认安装mysql8.0版本
安装:sudo apt install mysql-server
初始配置:sudo mysql_secure_installation
配置文件:vim /etc/mysql/mysql.conf.d/mysqld.cnf
本机端进入Mysql: sudo mysql
修改root密码:ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’;
select host, user, authentication_string from user;
修改密码后就不能使用sudo mysql空密码登录!
新建用户:create user newuser identified by 'password';
如果新建用户时发生强密码策略问题,
使用show variables like 'validate%';查看当前密码策略配置,
临时修改可使用set global validate_password.policy=LOW,set global validate_password.length=6,
如果要永久生效需要将参数写入配置文件[mysqld]单元下面。
用户授权:grant all privileges on dbname.* to 'newuser'%'%' with grant option;
查看用户授权:show grants for newuser;
修改服务器端编码:配置文件[mysqld]单元下面写入 character_set_server=utf8