创建用户

1
CREATE USER user1@127.0.0.1 IDENTIFIED  WITH mysql_native_password BY '123456';

user1 用户名

127.0.0.1 允许的IP地址。 IPV6::1 远程 % 本地 localhost127.0.0.1

mysql_native_password 加密方式。 旧的mysql_native_password,新的caching_sha2_password

修改密码

1
ALTER USER 'root'@'::1' IDENTIFIED WITH mysql_native_password BY '123456';

创建库

1
CREATE DATABASE tablename  CHARACTER SET utf8 -- UTF-8 Unicode COLLATE utf8_general_ci ;

ubuntu安装mysql后报错

Lost connection to MySQL server at 'waiting for initial communication packet', system error: 0
修改配置文件增加skip-name-resolve

vi /etc/my.cnf增加

1
2
[mysqld]
skip-name-resolve