加入收藏 | 设为首页 | 会员中心 | 我要投稿 佛山站长网 (https://www.0757zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

CentOS 6.2下如何使用YUM安装MySQL

发布时间:2016-09-30 16:57:30 所属栏目:MySql教程 来源:网络整理
导读:副标题 用yum安装MySql 打入如下命令: [root@mysql ~]# yum -y install mysql-server //自动从网上搜索资源并自动下载安装 [root@mysql ~]# chkconfig mysq

MySql初始化环境设置(四)

打入命令:mysql –u root

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql -u root' at line 1

弹出图上提示说明刚设置的密码已生效

下面通过密码登陆,打入命令:mysql –u root –p //在Enter password后输入刚才设置的密码,看到下面即表示登陆成功

[root@mysql ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 3

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; //查看系统已存在的数据库

use databasesname;   //选择需要使用的数据库

drop database databasename; //删除选定的数据库

exit    //退出数据库的连接

create database test01;    //建立名为test的数据库

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

| test01             |

+--------------------+

4 rows in set (0.00 sec)

可以看到新建的test01数据库

use test01;      //连接到数据库test01

mysql> use test01;

Database changed

mysql> create talbe test(num int,name varchar(50)); //在数据库中建立表

mysql> create table test(num int,name varchar(50));

Query OK, 0 rows affected (0.11 sec)

mysql> insert into test values(1,’Hello World!’) ;   //插入一个值到表中

mysql> create table test(num int,name varchar(50));

Query OK, 0 rows affected (0.11 sec)

select * from test;   //查看数据库中表的信息

mysql> select * from test;

+------+--------------+

| num | name         |

+------+--------------+

|    1 | Hello World! |

+------+--------------+

1 row in set (0.00 sec)

本栏目更多精彩内容:http://www.bianceng.cn/database/MySQL/

(编辑:佛山站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读