MySql 备忘
修改
初始化
# 避免索引长度错误
SET GLOBAL STORAGE_ENGINE = "InnoDb";
# 创建用户
CREATE USER "dbuser"@"localhost" IDENTIFIED BY 'password';
# 创建库
CREATE DATABASE dbname DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
# 授权用户拥有库的所有权限
GRANT ALL PRIVILEGES ON dbname.* TO "dbuser"@"%" IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
修改某一列值为另一列
UPDATE t_app_info SET creator_user_id = publisher_id;
错误
连接失败!null, message from server: "Host 'xxxx' is not allowed to connect to this MySQL server"
# 连接数据库
mysql -uroot -p
show databases;
use mysql;
# 查看用户对host的权限,如果root对应的只有localhost,那外部就无法访问
select user,host from user;
# 更新root权限
update user set host='%' where user='root'
# 刷新权限
flush privileges;