Home > Database > Mysql Tutorial > body text

MySQL新增用户以及数据库访问授权_MySQL

WBOY
Release: 2016-06-01 13:02:35
Original
1112 people have browsed it

# mysql -u root -p
# 允许本地 IP 访问 localhost, 127.0.0.1
# insert into mysql.user(Host,User,Password) values('localhost','zhouz',password('1234'));
# 允许外网 IP 访问
# insert into mysql.user(Host,User,Password) values('%','zhouz',password('1234'));
# 刷新授权
# flush privileges;
# 创建数据库
# create database zhouzdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
# 授予用户通过外网IP对于该数据库的全部权限
# grant all privileges on `zhouzdb`.* to 'zhouz'@'%' identified by '1234';
# 授予用户在本地服务器对该数据库的全部权限
# grant all privileges on `zhouzdb`.* to 'zhouz'@'localhost' identified by '1234';
# 刷新权限
# flush privileges;
# 退出 root 重新登录
# \q
# 已新帐号 zhouz 登录,由于使用的是 % 任意IP连接,所以需要指定外部访问IP
# mysql -u zhouz -h 192.168.1.168 -p
# 1234
Copy after login

平时难得用下 mysql 的命令行模式操作,今天弄下新建用户授权,遇到些问题在这里简单整理下

注意: 若仅开放外网访问权限,则本地是无法访问的,需要本地服务器也能访问 mysql 则要增加本地访问权限

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!