> create user 'tom'@'%' identified by '123456'; # 创建角色 > create database gogsdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci; # 创建数据库 > grant all privileges on gogsdb.* to 'tom'@'%' identified by '123456'; # 授权数据库访问方式 > flush privileges; # 刷新权限
测试链接
1 2 3
root@2223c7921732:/# mysql -utom -p123456 gogsdb; mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 104 Server version: 5.7.22 MySQL Community Server (GPL) ...