超简版4步Linux下RPM安装mysql

(1)安装三个包
[root@orcl Packages]#yum install mysql*
1.mysql-devel
2.mysql-serve
3.mysql


[root@orcl Packages]# rpm -qa|grep mysql
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
mysql-devel-5.1.71-1.el6.i686
mysql-libs-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-bench-5.1.71-1.el6.x86_64
mysql-connector-java-5.1.17-6.el6.noarch
mysql-5.1.71-1.el6.x86_64
mysql-devel-5.1.71-1.el6.x86_64
mysql-libs-5.1.71-1.el6.i686
mysql-test-5.1.71-1.el6.x86_64


(2)开启mysql数据库服务
[root@orcl Packages]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
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 orcl.wuyutong 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!


                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]


(3)登录数据库


[root@orcl Packages]# mysql -u root --------------登录
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.71 Source distribution


Copyright (c) 2000, 2013, 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> set password for root@localhost=password('123456');---------设置密码
Query OK, 0 rows affected (0.01 sec)


mysql> show databases;--------------显示数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)


[root@orcl Packages]# mysql -u root -p----------第二次登录要-p,用密码

(4)使用数据库

mysql> ? contents----------------查看帮助信息用“?”,显示所有帮助就是加上contents
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
   Account Management
   Administration
   Compound Statements
   Data Definition
   Data Manipulation
   Data Types
   Functions
   Functions and Modifiers for Use with GROUP BY
   Geographic Features
   Help Metadata
   Language Structure
   Plugins
   Procedures
   Storage Engines
   Table Maintenance
   Transactions
   User-Defined Functions
   Utility


mysql> 




mysql> ? data definition
You asked for help about help category: "Data Definition"
For more information, type 'help <item>', where <item> is one of the following
topics:
   ALTER DATABASE
   ALTER EVENT
   ALTER FUNCTION
   ALTER LOGFILE GROUP
   ALTER PROCEDURE
   ALTER SERVER
   ALTER TABLE
   ALTER TABLESPACE
   ALTER VIEW
   CONSTRAINT
   CREATE DATABASE
   CREATE EVENT
   CREATE FUNCTION
   CREATE INDEX
   CREATE LOGFILE GROUP
   CREATE PROCEDURE
   CREATE SERVER
   CREATE TABLE
   CREATE TABLESPACE
   CREATE TRIGGER
   CREATE VIEW
   DROP DATABASE
   DROP EVENT
   DROP FUNCTION
   DROP INDEX
   DROP LOGFILE GROUP
   DROP PROCEDURE
   DROP SERVER
   DROP TABLE
   DROP TABLESPACE
   DROP TRIGGER
   DROP VIEW
   RENAME TABLE
   TRUNCATE TABLE


mysql> 


mysql> select database();-----------------显示数据库名
+------------+
| database() |
+------------+
| wyt        |
+------------+
1 row in set (0.00 sec)


mysql> select user();-----------当前用户名
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)


mysql> select version();-------当前数据库版本
+-----------+
| version() |
+-----------+
| 5.1.71    |
+-----------+
1 row in set (0.39 sec)


查看时间
mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 14:54:37  |
+-----------+
1 row in set (0.00 sec)


mysql> select curdate();
+------------+
| curdate()  |
+------------+
| 2016-09-24 |
+------------+
1 row in set (0.00 sec)


mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2016-09-24 14:54:51 |
+---------------------+
1 row in set (0.00 sec)


mysql> 



mysql> create database wyt;----------创建数据库
Query OK, 1 row affected (0.12 sec)


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| wyt                |
+--------------------+
4 rows in set (0.07 sec)


mysql> use wyt;------------指定用哪一个数据库
Database changed


mysql> create table yangyang (a int);-------创建表
Query OK, 0 rows affected (0.20 sec)


mysql> insert into yangyang values (1);--------在表中插入数据
Query OK, 1 row affected (0.49 sec)


mysql> select * from yangyang;----------查询
+------+
| a    |
+------+
|    1 |
+------+
1 row in set (0.30 sec)


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| wyt                |
+--------------------+
4 rows in set (0.02 sec)


mysql> drop database wyt;----------删除数据库
Query OK, 1 row affected (1.47 sec)


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)


mysql> create table tt (id number,name char(10));
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 'number,name char(10))' at line 1
mysql> create table tt (id int,name char(10));-----------数据类型的不同
Query OK, 0 rows affected (0.18 sec)


mysql> show tables;-----------显示当前数据库中有哪些表
+---------------+
| Tables_in_wyt |
+---------------+
| tt            |
+---------------+
1 row in set (0.00 sec)



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值