# 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. C#基础-委托与事件

    委托 delegate是申明委托的关键字 返回类型都是相同的,并且参数类型个数都相同 委托声明 delegate double DelOperater(double num1, double num2 ...

  2. Mplab X IDE 安装DMCI

     DMCI在Mplab 8中是默认安装的,在 Mplab X IDE中是作为插件,默认不安装.   找到     勾选前面的复选框,点击安装

  3. 动态调试smali代码

    Android Killer对应用进行反编译为smali代码,看看Manifest文件中application标签里面是否有android:debuggable="true",没有 ...

  4. python基础之装饰器扩展和迭代器

    wraps模块 让原函数保留原来的说明信息 import time import random from functools import wraps def auth(func): '''auth ...

  5. 内置函数--sorted,filter,map

    sorted() 排序函数. 语法: sorted(Iterable, key=None, reverse=False) Iterable: 可迭代对象;  key: 排序规则(排序函数); reve ...

  6. 2 实现第一个Django网站 博客

    -1.理解上下文 render()渲染 request  url传来的reuqest x.html 制定返回的模板名称 context 上下文    数据库中 替换数据 0.大框架 1.创建模板 (1 ...

  7. 读json文件发生错误,所遇到的坑

    当我们生产者生产json 文件的时候   消费时用JSON读文件时,如下: val values = kafkardd.map(t=>JSON.parseObject(t._2)) 如果发生以下 ...

  8. 《算法》C++代码 Floyd

    今天写写最短路径的Floyd算法(有翻译叫弗洛伊德,不过这奇葩翻译用来读读就好……). 这个算法的实质,广义来讲,其实是DP(动态规划).其实按说,算法应该先说说什么贪心.搜索.DP.二分之类的基本算 ...

  9. android 摄像头相关使用记录

    检测闪光灯是否存在 部分手机不存在闪光灯,检测是否存在还是有必要的. boolean hasFlash = this.getPackageManager().hasSystemFeature(Pack ...

  10. python判断mongodb--find(),find_one()返回是否为空

    conn = MongoClient('127.0.0.1', 27017)db = conn.diffcollection = db['test1']result = collection.find ...