mysql 安装和简单应用

1. yum install mysql

2. yum install mysql-server          yum install mysql-devel

3. /etc/rc.d/init.d/mysql restart

4. mysql -u root

5. grant 添加用户

格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"

6. use 数据库名称

7. flush privileges;

8. 修改密码
格式:mysqladmin -u用户名 -p旧密码  password 新密码

9. 连接mysql
格式: mysql -h主机地址 -u用户名 -p用户密码

10.显示命令
  1、显示数据库列表。
     show databases;
  刚开始时才两个数据库:mysql和test。mysql库很重要它里面有mysql的系统信息,我们改密码和新增用户,实际上就是用这个库进行操作。
  2、显示库中的数据表:
     use mysql;

     show tables;
  3、显示数据表的结构:
     describe 表名;
  4、建库:
     create database 库名;
  5、建表:
     use 库名;
     create table 表名 (字段设定列表);
  6、删库和删表:
     drop database  库名;
     drop table  表名;
  7、将表中记录清空:
     delete from 表名;
  8、显示表中的记录:
     select * from 表名;

 

错误处理:

 

1. 错误信息:

Stopping MySQL:                                            [FAILED]
Initializing MySQL database:  Neither host 'vm0000182' nor 'localhost' could be looked up with
/usr/bin/resolveip
Please configure the 'hostname' command to return a correct hostname.
If you want to solve this at a later stage, restart this script with
the --force option
                                                           [FAILED]

原因: 原因是/etc/hosts 文件为空的关系。

修改方法:在 /etc/hosts 文件中添加下面信息:

#localhost
127.0.0.1               localhost.localdomain localhost

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值