create user 'username'@'ip' identified by 'password'; flush privileges;
create database name character set utf8; grant all privileges on database.* to 'username'@'ip';
配置文件
sudo vim /etc/mysql/my.cnf
1
# bind-address = 127.0.0.1 # 允许远程用户登录
错误
Access denied for user ‘root’@‘localhost’ ;
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
1 2
[mysqld] skip-grant-tables
操作
1 2 3 4 5 6
mysql -u root -p use mysql; update user set authentication_string='' where user='root'; update user set plugin="mysql_native_password" where user='root'; flush privileges; quit;
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
1 2
[mysqld] # skip-grant-tables
操作
1 2 3 4
service msqld restart
mysql -u root -p ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';