码迷,mamicode.com
首页 > 数据库 > 详细

mysql学习笔记

时间:2017-11-28 11:56:17      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:markdown   查看   cte   evo   option   授权   star   性能   其他   

安装

yum install mysql
yum install mysql-server
yum install mysql-devel

启停

service mysqld start

ps -ef | grep mysqld

root@host# cd /usr/bin
./mysqladmin -u root -p shutdown
Enter password: ******

修改root密码

mysqladmin -u root password "new_password";

[root@host]# mysql -u root -p
Enter password:*******

创建用户

. 方法1:在 mysql 数据库中的 user 表添加新用户

root@host# mysql -u root -p
Enter password:*******
mysql> use mysql;
Database changed

mysql> INSERT INTO user 
          (host, user, password, 
           select_priv, insert_priv, update_priv) 
           VALUES (‘localhost‘, ‘guest‘, 
           PASSWORD(‘guest123‘), ‘Y‘, ‘Y‘, ‘Y‘);
Query OK, 1 row affected (0.20 sec)

mysql> FLUSH PRIVILEGES;

. 方法2:通过SQL的 GRANT 命令

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    -> ON TUTORIALS.*
    -> TO ‘zara‘@‘localhost‘
    -> IDENTIFIED BY ‘zara123‘;

常用命令

. show databases
. use 数据库名
. show tables
. show columns from 表名
. show index from 表名
. SHOW TABLE STATUS LIKE [FROM db_name] [LIKE ‘pattern‘] \G: 该命令将输出Mysql数据库管理系统的性能及统计信息。
. show grants;查看当前用户(自己)权限:
. show grants for dba@localhost; 查看其他 MySQL 用户权限:
. grant all on . to dba@localhost;赋权
. revoke all on . from dba@localhost;撤销权限
. grant select on testdb.* to dba@localhost with grant option; 如果想让授权的用户,也可以将这些权限 grant 给其他用户,需要选项 grant option

mysql学习笔记

标签:markdown   查看   cte   evo   option   授权   star   性能   其他   

原文地址:http://www.cnblogs.com/abcyrf/p/7908491.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!