mysql基本命令
mysql连接
mysql -u 用户名 -h ip -p
创建用户
CREATE USER 'aiop1'@'LOCALHOST' IDENTIFIED BY '密码';
赋值权限
grant all privileges on *.* to aiop1@localhost identified by '12345678';
报错解决
但是MySQL8.0以后的版本,会出现:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax…的错误
查看版本
select version();
解决办法 (3个命令要依次执行)
create user test@'localhost' identified by '123456';
grant all privileges on *.* to test@'localhost';
flush privileges;
删除用户
delete from mysql.user where Host = '%' and User = '用户名';
修改允许远程主机连接mysql
update user set user.Host = '%' where user.User = '用户名';
flush privileges;
选中mysql库
use mysql;
显示用户下所有的库
show databases;
查看所有的用户
use mysql;
select * from user;