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 common_user@’%’
或者,用一条 MySQL 命令来替代:
grant select, insert, update, delete on testdb.* to common_user@’%’
9>.grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 MySQL 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; -- now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; -- now, you can drop a procedure
grant execute on testdb.* to developer@’192.168.0.%’;
10>.grant 普通 DBA 管理某个 MySQL 数据库的权限。
grant all privileges on testdb to dba@’localhost’
其中,关键字 “privileges” 可以省略。
11>.grant 高级 DBA 管理 MySQL 中所有数据库的权限。
grant all on *.* to dba@’localhost’
12>.MySQL grant 权限,分别可以作用在多个层次上。
1. grant 作用在整个 MySQL 服务器上:
grant select on *.* to dba@localhost; -- dba 可以查询 MySQL 中所有数据库中的表。
grant all on *.* to dba@localhost; -- dba 可以管理 MySQL 中的所有数据库
2. grant 作用在单个数据库上:
grant select on testdb.* to dba@localhost; -- dba 可以查询 testdb 中的表。
3. grant 作用在单个数据表上:
grant select, insert, update, delete on testdb.orders to dba@localhost;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5. grant 作用在存储过程、函数上:
grant execute on procedure testdb.pr_add to ’dba’@’localhost’
grant execute on function testdb.fn_add to ’dba’@’localhost’
注意:修改完权限以后 一定要刷新服务,或者重启服务,刷新服务用:FLUSH PRIVILEGES。权限 | 说明 |
all | |
alter | |
alter routine | 使用alter procedure 和drop procedure |
create | |
create routine | 使用create procedure |
create temporary tables | 使用create temporary table |
create user | |
create view | |
delete | |
drop | |
execute | 使用call和存储过程 |
file | 使用select into outfile 和load data infile |
grant option | 可以使用grant和revoke |
index | 可以使用create index 和drop index |
insert | |
lock tables | 锁表 |
process | 使用show full processlist |
reload | 使用flush |
replication client | 服务器位置访问 |
replocation slave | 由复制从属使用 |
select | |
show databases | |
show view |
shutdown | 使用mysqladmin shutdown 来关闭mysql |
super | |
update | |
usage | 无访问权限 |
原始文件安放的位置是:/usr/local/src/MySQL-5.6.25-1.linux_glibc2.5.x86_64.rpm-bundle.tar.
1.安装本MySQL-5.6.25-1.linux_glibc2.5.x86_64.rpm-bundle.tar的方式:a.b.c.d.e
a.检测是否已经安装了Mysql 命令:
rpm -qa|grep -i mysql
b.如果有,先对原来的MySql删除,命令:
yum -y remove package_name 或者rpm -ev package_name 或者 rpm -e package_name
c.再执行如下命令:
rm -f /etc/my.cnf
rm -rf /var/lib/mysql
d.查看残留的目录:
whereis mysql
e.然后删除mysql目录:
rm -rf /usr/lib64/mysql
rm -rf /usr/local/mysql
2.解压安装包MySQL-5.6.25-1.linux_glibc2.5.x86_64.rpm-bundle.tar,并开始安装:a.b.c
a.解压MySQL-5.6.25-1.linux_glibc2.5.x86_64.rpm-bundle.tar,命令:
tar -xvf MySQL-5.6.25-1.linux_glibc2.5.x86_64.rpm-bundle.tar ,留下其中的client和server,其他的均删掉.
b.执行安装的操作,命令如下:
rpm -ivh MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm
c.重启机器(如果不重启,有时候容易出问题.)
3.授权root用户远程访问:
a.进入 mysql,输入密码:
mysql -u root -p
b.使用 mysql库 :
use mysql;
c.查看用户表 :
SELECT Host,User FROM user;
d.更新用户表 :
UPDATE user SET Host = '%' WHERE User = 'root' LIMIT 1;
e.执行权限命令:
grant all on *.* to 'root'@'%' identified by 'root';
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
(使任何人都可以访问主机:
1. mysql -h localhost -u root
2. grant all privileges on *.* to 'root'@'%' with grant option;
3. flush privileges;
)
f.使修改生效 :flush privileges;
4.防火墙开放3306端口: a.b.c.d
a.登陆mysql:mysql -u root -p 密码
b.编辑文件:vi /etc/sysconfig/iptables
c.增加一行:-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
d.重启防火墙:service iptables restart
5.创建一个用户,拥有root权限:a.b.c.d
a.CREATE USER 'togeek' IDENTIFIED BY 'togeek';
b.grant all on *.* to 'togeek'@"%" Identified by "togeek";
c.grant all privileges on *.* to 'togeek'@'%' with grant option;
d.flush privileges;
最好用root用户还执行下:
/etc/init.d/mysql restart
通过以上这些操作,mysql 速度的安装上去了,而且是速速的使用(如果搞不定,我真的是该苦笑了,都搞的这么清楚了...).