# yum install mysql-server

# /etc/init.d/mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h CentOS1.eric.com password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

============================================================================================================================================
# mysqladmin -u root password 'password'
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql> create database wordpress;
Query OK, 1 row affected (0.02 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
| wordpress |
+--------------------+
4 rows in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* to 'wordpress'@'localhost' IDENTIFIED BY 'wordpress' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> create database bank;
Query OK, 1 row affected (0.00 sec)

mysql> create database shop;
Query OK, 1 row affected (0.00 sec)

mysql> create database hospital;
Query OK, 1 row affected (0.01 sec)

mysql> grant select,insert,update,delete,create,drop
-> on bank.*
-> to 'custom'@'localhost'
-> identified by 'obscure';
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,insert,update,delete,create,drop on shop.* to 'custom'@'localhost' identified by 'obscure';
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,insert,update,delete,create,drop on hospital.* to 'custom'@'localhost' identified by 'obscure';
Query OK, 0 rows affected (0.00 sec)
============================================================================================================================================
# mysql bank -u custom -p
mysql> use bank;
mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
+----------------+
| Tables_in_bank |
+----------------+
| pet |
+----------------+
1 row in set (0.00 sec)

mysql> DESC pet;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| owner | varchar(20) | YES | | NULL | |
| species | varchar(20) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
| birth | date | YES | | NULL | |
| death | date | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)

mysql> insert into pet values ('Puffball','Diane','hamster','f','2001-02-01',NULL);
Query OK, 1 row affected (0.01 sec)
mysql> insert into pet values ('Puffbffff','eric','hamster','f','2022-02-01',NULL);
Query OK, 1 row affected (0.00 sec)
mysql> insert into pet values ('Pub','laszy','hamster','f','2222-02-01',NULL);
Query OK, 1 row affected (0.00 sec)

mysql> select * from pet;
+-----------+-------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-----------+-------+---------+------+------------+-------+
| Puffball | Diane | hamster | f | 2001-02-01 | NULL |
| Puffbffff | eric | hamster | f | 2022-02-01 | NULL |
| Pub | laszy | hamster | f | 2222-02-01 | NULL |
+-----------+-------+---------+------+------------+-------+
3 rows in set (0.00 sec)

mysql> select * from pet where name='Pub';
+------+-------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+------+-------+---------+------+------------+-------+
| Pub | laszy | hamster | f | 2222-02-01 | NULL |
+------+-------+---------+------+------------+-------+
1 row in set (0.00 sec)

mysql> select name, owner from pet;
+-----------+-------+
| name | owner |
+-----------+-------+
| Puffball | Diane |
| Puffbffff | eric |
| Pub | laszy |
+-----------+-------+
3 rows in set (0.00 sec)

MySQL基本管理和应用的更多相关文章

  1. [MySQL Reference Manual] 5 MySQL 服务管理

    5. MySQL 服务管理 5. MySQL 服务管理 5.1 The Mysql Server 5.2 Mysql 服务日志 5.2.1 选择General query log和slow query ...

  2. MySQL日志管理

    MySQL日志管理 2013年09月26日 ⁄ MySQL ⁄ 共 14266字 ⁄ 评论数 ⁄ 被围观 , views+ 一.日志类型: MySQL有几个不同的日志文件,可以帮助你找出mysqld内 ...

  3. MySQL 日志管理详解

    大纲 一.日志分类 二.日志详解 注:MySQL版本,Mysql-5.5.32(不同版本的mysql变量有所不同) 一.日志分类 错误日志 查询日志 慢查询日志 二进制日志 中继日志 事务日志 滚动日 ...

  4. mysql监控管理工具--innotop

    https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/innotop/innotop-1.9. ...

  5. MySQL账户管理

    body { font-family: Helvetica, arial, sans-serif; font-size: 14px; line-height: 1.6; padding-top: 10 ...

  6. MySQL(十六)之MySQL用户管理

    一.MySQL用户管理概述 MySQL是一个多用户的数据库,MYSQL的用户可以分为两大类: 超级管理员用户(root),拥有全部权限 普通用户,由root创建,普通用户只拥有root所分配的权限 二 ...

  7. MySQL用户管理及SQL语句详解

    1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysql.user; +--------+--- ...

  8. Mysql的管理及使用

    第1章 Mysql的管理 1.1 连接管理mysql mysql[options] #Linux或UNIX shell提示符(终端窗口) mysql --help #查看帮助信息 mysql --ve ...

  9. MySQL 索引管理与执行计划

    1.1 索引的介绍 索引是对数据库表中一列或多列的值进行排序的一种结构,使用索引可快速访问数据库表中的特定信息.如果想按特定职员的姓来查找他或她,则与在表中搜索所有的行相比,索引有助于更快地获取信息. ...

  10. 库增删该查,表增删该查,记录增删该查,表与表关系(多对多,多对一,一对一),mysql用户管理

    库增删该查 增加库 create database db1 create database db1 charset="gbk 查看库 show databases 查看所有库 show cr ...

随机推荐

  1. asciinema使用

    asciinema让您轻松记录终端会话,并在终端和网页浏览器中重播它们. 安装最新版本: sapt-get install asciinema 记录你的第一个终端视频: asciinema rec f ...

  2. struts2属性驱动模型

    属性驱动模型的作用: 因为struts2与servlet API 实现了解耦,无法直接使用HttpServlet Request对象获取表单提交的参数,但Struts2提供了属性驱动模型机制来解决这个 ...

  3. 申请qq第三方登录 http://www.php20.com/forum.php?mod=viewthread&tid=29 (出处: 码农之家)

    百度  qq互联  进入网站 按图中的步骤申请第三方登录即可 先申请成为开发者 审核通过后再继续操作 提交 后列表中会出现提交的申请. 状态为审核中,审核通过会得到下图. 点查看 红线后面就是appi ...

  4. 简单的for循环实现九九乘法表

    PHP for 循环 语法 for (init counter; test counter; increment counter) { code to be executed; } 参数: init ...

  5. jQuery-laye插件实现 弹框编辑,异步验证,form验证提交

    代码中用到了 jQuery的ajax异步处理,each()循环,submit()页面验证提交form表单,prepend()追加标签,laye插件的弹框效果(如有其它弹框效果可参考官网:http:// ...

  6. java中的运算(2013-05-03-bd 写的日志迁移

    // ++自加 --自减 int a=9; a++; // a=a+1; System.out.println(a); // a=10 a--; // a=a-1 System.out.println ...

  7. Hbase运维参考(项目)

    1 Hbase日常运维 1.1 监控Hbase运行状况 1.1.1 操作系统 1.1.1.1 IO 群集网络IO,磁盘IO,HDFS IO IO越大说明文件读写操作越多.当IO突然增加时,有可能:1. ...

  8. PHP.TP框架下商品项目的优化1-时间插件、鼠标所在行高亮、布局规划页面

    1.优化搜索表单中按时间搜索的功能 添加一个时间插件datetimepicker,在lst.html中,注意要导入jquery.min.js,此处从前文的在线编辑器中导入 <!-- 导入 --& ...

  9. BZOJ 2907: 拜访神犇

    设最优策略为第一步向左走 那么肯定是走到最左边最优 需要补一些步数 一种是最右边的连着选,多出一倍代价 一种是不连着选,多出两倍代价 #include<cstdio> #include&l ...

  10. 成员变量和属性区别(@property那点事儿)

    历史由来: 接触iOS的人都知道,@property声明的属性默认会生成一个_类型的成员变量,同时也会生成setter/getter方法. 但这只是在iOS5之后,苹果推出的一个新机制.看老代码时,经 ...