MySQL基本管理和应用
# 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基本管理和应用的更多相关文章
- [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 ...
- MySQL日志管理
MySQL日志管理 2013年09月26日 ⁄ MySQL ⁄ 共 14266字 ⁄ 评论数 ⁄ 被围观 , views+ 一.日志类型: MySQL有几个不同的日志文件,可以帮助你找出mysqld内 ...
- MySQL 日志管理详解
大纲 一.日志分类 二.日志详解 注:MySQL版本,Mysql-5.5.32(不同版本的mysql变量有所不同) 一.日志分类 错误日志 查询日志 慢查询日志 二进制日志 中继日志 事务日志 滚动日 ...
- mysql监控管理工具--innotop
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/innotop/innotop-1.9. ...
- MySQL账户管理
body { font-family: Helvetica, arial, sans-serif; font-size: 14px; line-height: 1.6; padding-top: 10 ...
- MySQL(十六)之MySQL用户管理
一.MySQL用户管理概述 MySQL是一个多用户的数据库,MYSQL的用户可以分为两大类: 超级管理员用户(root),拥有全部权限 普通用户,由root创建,普通用户只拥有root所分配的权限 二 ...
- MySQL用户管理及SQL语句详解
1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysql.user; +--------+--- ...
- Mysql的管理及使用
第1章 Mysql的管理 1.1 连接管理mysql mysql[options] #Linux或UNIX shell提示符(终端窗口) mysql --help #查看帮助信息 mysql --ve ...
- MySQL 索引管理与执行计划
1.1 索引的介绍 索引是对数据库表中一列或多列的值进行排序的一种结构,使用索引可快速访问数据库表中的特定信息.如果想按特定职员的姓来查找他或她,则与在表中搜索所有的行相比,索引有助于更快地获取信息. ...
- 库增删该查,表增删该查,记录增删该查,表与表关系(多对多,多对一,一对一),mysql用户管理
库增删该查 增加库 create database db1 create database db1 charset="gbk 查看库 show databases 查看所有库 show cr ...
随机推荐
- 使用IDEA将本地项目上传到GitHub
00.首先保证git和github能够使用ssh连接. 01.在GitHub上新建仓库 需要注意的是不要勾选Initialize this repository with a README. 02.在 ...
- IDEA 编辑框光标闪烁
依次打开如下菜单: File -> Settings -> Editor -> General -> Appearance -> 选中 Caret blinking (m ...
- Gulp工具
Gulp是一个基于node开发的构建工具. gulp本身是不进行任何构建任务,是通过gulp的一些列插件完成: gulp-less 编译LESS文件: gulp-autoprefix 添加css私 ...
- 微信小程序真机定位问题技巧
小程序导航 https://wq.xmaht.top 开发者在开发小程序的时候可能会碰到一些这样的问题: 问题1 开发者工具上看效果没问题,但是在真机上测试不行? 问题2 有用户遇到小程序功能无法 ...
- 关于IT术语---ip、uv、pv、tps、qps、rps
涉及到IT方面的几条术语,这里要好好说道说道: 只要和网站打交道,难免会经常听到一系列的转有名词 >>> 系统今日UV多少.PV多少.QPS多少之类的问题.这里就对这些常见的术语 ...
- 转-Spark编程指南
Spark 编程指南 概述 Spark 依赖 初始化 Spark 使用 Shell 弹性分布式数据集 (RDDs) 并行集合 外部 Datasets(数据集) RDD 操作 基础 传递 Functio ...
- SpringCloud框架搭建+实际例子+讲解+系列五
(4)服务消费者,面向前端或者用户的服务 本模块涉及到很多知识点:比如Swagger的应用,SpringCloud断路器的使用,服务API的检查.token的校验,feign消费者的使用.大致代码框架 ...
- python3 练习题100例 (十八)托儿所问题
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """练习十八:某托儿所有大.中.小三个班级,其儿童月龄分别用如下 三个列表 ...
- sed命令例子详解
sed -e '/Patricia/h' -e '/Margot/x' datafile 包含Margot的行将被包含Patricia的行替换: sed -e /WE/{h;d;}' -e '/CT/ ...
- POJ:3685-Matrix
Matrix Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 7879 Accepted: 2374 Description Gi ...