数据库相关

MySQL篇: - The world's most popular open source database http://www.mysql.com/ 多用户,多线程的强壮的关系数据库服务器

http://supportopensource.iteye.com/blog/1415527 Windows7下MySQL5.5.20免安装版的配置
MySQL Windows安装包说明:
1、mysql-5.5.20-win32.msi:Windows 安装包,图形化的下一步下一步的安装。
2、mysql-5.5.20.zip,这个是windows源文件,需要编译,对应的Linux源文件是mysql-5.5.20.tar.gz
3、mysql-5.5.20-win32.zip,这个文件解包后即可使用,是编译好的windows32位Mysql。

MySQL安装目录的bin目录下的mysql.exe程序是MySQL的客户程序,它支持在命令行输入SQL语句。

在MySQL安装后,还有一个初始用户root,MySQL的安全验证机制要求用户为root重新设置口令 

  1. Download installation file and JDBC driver
  2. Unzip installation file and double click setup.exe will install MySQL 

MySQL服务器即可以作为前台服务程序运行,也可以作为后台服务程序运行。

        前台服务程序运行方法:

MySQL安装目录的bin目录下双击mysqld.exe – 最基本的MySQL服务器程序

                                                        Mysqld-nt.exe – NT/2000/XP平台的优化版本,支持命名管道

        后台服务程序运行方法:

  1. 在DOS下转到MySQL的安装目录的bin子目录下
  2. 在Windows中注册MySQL服务,输入命令: mysqld-nt –install
  3. 启动MySQL服务,输入命令:net start mysql  停止服务命令:net stop mysql  删除服务命令:mysqld-nt -remove

也可以通过【控制面板】->【管理工具】->【服务】菜单来管理注册过的MySQL服务。

当MySQL服务器启动后,按照以下步骤为root用户设置口令,并且创建新用户dbuser,口令为1234

  1. 在DOS下转到MySQL的安装目录的bin子目录下
  2. 在DOS命令行输入命令:mysql
  3. 进入mysql数据库,SQL命令为:use mysql
  4. 为root用户重新设置口令,新的口令为1234:

update USER set PASSWORD=password(‘1234’) where USER=’root’;

flush privileges;

  1. 退出mysql客户程序:exit
  2. 以root用户身份进入mysql客户程序:mysql -u root -p当系统提示输入口令时,输入1234
  3. 进入mysql数据库,创建一个新的用户dbuser,口令为1234,:

use mysql;

grant all privileges on *.* to dbuser@localhost identified by ‘1234’ with grant option;

接下来创建BookDB数据库和BOOKS表,并向BOOKS表中插入数据,具体步骤如下

  1. 创建数据库:create database BookDB;
  2. 进入BookDB数据库:user BookDB
  3. 在BookDB数据库中创建BOOKS表:

create table BOOKS(

ID varchar(8) primary key,

 NAME varchar(24),

 TITLE varchar(96),

 PRICE float,

 YR int,

 DESCRIPTION varchar(128),

SALE_AMOUNT INT);

     4.在BOOKS表中加入一些记录:

insert into BOOKS values(‘201’, ‘孙卫琴’, ‘Java面向对象编程’, 65, 2006, ‘掌握Java’, 20000);

ZIP文件解压缩后直接使用之绿色版本:

1. Create my.ini from my-default.ini in your uncompressed mysql base directory (ex. D:/mysql)
Modify the content of the file as bellow :

[mysqld]

# set basedir to your installation path
basedir=D:/mysql

# set datadir to the location of your data directory
datadir=D:/mysql/data

2. User the command bellow to start mysql service:
D:mysqlinmysqld --console

3. Test the mysql database service command:

mysqlshow
mysqlshow -u root mysql
mysqladmin version status proc
mysql test (Login test database)

4. Change the password of root user

mysqladmin -u root password "newpass"
mysqladmin -u root password oldpass "newpass"

5. Login mysql use root and password
mysql -u root -p
Input your password on the prompt

After login the mysql server, you can create your own databases with sql.

6. Change database to the test database
use test;
Show the tables of the database
show tables;

After change the database, you can create your table and insert some records into your table.

7. Create windows service for mysql
Stop mysql database service
mysqladmin -u root -p shutdown
Start a command prompt using admin privilege
mysqld --install MySQL_gh
Then you can see a service have been create in your windowns service management console.

Delete mysql service
sc delete MySQL_gh

8. About the GUI tool for mysql you can download a 30 days trial version of SQLyog MySQL GUI on the site bellow :
https://www.webyog.com/
Or download MySQL Workbench from oracle site

Or download Navicat for MySQL
http://www.navicat.com.cn/download

MySQL Workbench from oracle site
It is a oracle free software.

SQL Statements:

C:windowssystem32>mysql -u root -p sampledb
Enter password: password
mysql> use sampledb;
mysql> show tables;
mysql> select * from t_user;
mysql> INSERT INTO t_user (user_name,password) VALUES('user','123456');
mysql> UPDATE t_user SET password='12345' where user_name='user';
mysql> DELETE FROM t_user where user_name='user';
mysql> DELETE FROM t_user where user_id='2' or '3' or '4' or '5';

原文地址:https://www.cnblogs.com/vanessabutterfly/p/3189898.html