添加新用户 允许本地 IP 访问 localhost, 127.0.0.1 create user 'test'@'localhost' identified by '123456'; 允许外网 IP 访问 create user 'test'@'%' identified by '123456'; 刷新授权 flush privileges; 为用户创建数据库 create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
insert into mysql.user(Host,User,Password) values("%","admin",password("admin")); grant all privileges on *.* to 'admin' identified by 'admin'; grant all privileges on *.* to admin@localhost identified by 'admin'; grant all p
mysql给用户赋予所有权限(包括远程连接) 我们给mysql新创建的用户,希望它拥有更多权限,比如远程连接,方便我们操作,可以使用如下命令: GRANT ALL PRIVILEGES ON *.* TO "zhang"@"%" IDENTIFIED BY "12345" WITH GRANT OPTION; 格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by "用户密码";这个操作
mysql在最新的版本中会生成随机密码,存储在/etc/my.conf的文件中,但是大多数使用者不会在意这个,因为随机的密码识别性太差,所以我们可以自己配置数据库用户以及设置密码. 设置跳过密码登陆root用户 skip.grant.table 登陆 mysql -u root -p 修改用户密码 update user set password=password("1q2w3e4r") where user="root"; flush privileges; 创建
MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant select on testdb.* to common_user@'%' grant insert on testdb.* to common_user@'%' grant update on testdb.* to common_user@'%' grant delete on testdb.* to c
因为我们目前只有root,所以只能先用root登陆mysql,再新增用户: $ bin/mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id Server version: MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates