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搭建SSM出现的一些错误
下面是我这几天整合SpringMVC+Spring+MyBatis框架遇到的一些问题 ,在这里总结一下: 1:HTTP Status 500 - Request processing failed; ...
- js表格打印自动分页demo
本文翻译自:How Does setState Know What to Do? 原作者:Dan Abramov 如果有任何版权问题,请联系shuirong1997@icloud.com 当你在组件中 ...
- Ansible学习 Patterns
Ansible中ad-hoc命令格式如下:ansible <pattern_goes_here> -m <module_name> -a <arguments>,P ...
- Oauth2.0协议 http://www.php20.com/forum.php?mod=viewthread&tid=28 (出处: 码农之家)
概要 OAuth2.0是OAuth协议的下一版本,但不向后兼容OAuth 1.0即完全废止了OAuth1.0. OAuth 2.0关注客户端开发者的简易性.要么通过组织在资源拥有者和HTTP服 ...
- 残留的linux相关笔记
1. 设置网络环境1) 设置宿主机网络环境#ifconfig eth1 192.168.16.111 2) 设置开发板网络环境>pri>setenv ipaddr 192.168.16.2 ...
- 1,MongoDB简介和安装
一.初识MongoDB MongoDB 是一个基于分布式文件存储的数据库.由 C++ 语言编写.旨在为 WEB 应用提供可扩展的高性能数据存储解决方案. MongoDB 是一个介于关系数据库和非关系数 ...
- 4034: [HAOI2015]树上操作
4034: [HAOI2015]树上操作 链接 思路: 树链剖分.操作:单点修改,路径查询,子树修改. 代码: #include<cstdio> #include<algorithm ...
- USACO刷题之路,开始了
几天前,重新开始刷题了. 重新刷题有几个原因: 1.曾经的OI经历,如今除了悟性高些.知识多些,大多已经遗忘.不希望真的让之前的OI水平就这么丢了. 2.越来越觉得,刷题真的是一件很开心的事情.大学中 ...
- Jmeter测试SOAP协议(Jmeter 3.3)
公司协议都是SOAP协议的,最初在网上看到Jmeter测试soap协议需要插件,但是Jmeter3.2开始就不在支持该插件,后来又查了些资料,找到了解决办法,Jmeter提供专门创建针对soap协议的 ...
- 【转载】全面解析Unity3D自动生成的脚本工程文件
我们在Unity3D开发的时候,经常会看到它会产生不少固定命名工程文件,诸如: Assembly-CSharp-vs.csproj Assembly-CSharp-firstpass-vs.csp ...