ubuntu环境 MySQL数据库 实验练习环境的搭建
ubuntu环境 MySQL数据库 实验练习环境的搭建 写在前面啰啰嗦嗦的话: 某些高校一门课程居然上课教材都没有.当然,没教材也是件好事,此处不把话说得太直白比较好. 各种Microsoft搞出来的东西,MS你大爷啊.闭源SQL学了有个球用啊. 本来想好好根据Redis学
ubuntu环境 MySQL数据库 实验练习环境的搭建
写在前面啰啰嗦嗦的话:
某些高校一门课程居然上课教材都没有.当然,没教材也是件好事,此处不把话说得太直白比较好.
各种Microsoft搞出来的东西,MS你大爷啊.闭源SQL学了有个球用啊.
本来想好好根据Redis学学数据库的,还是没学.坦诚的讲,一方面自己去做其他的事情去了(图像,数据结构,OS...)但是,没有去看Redis的源码还是觉得很遗憾,希望以后有时间能去学习Redis.
既然SQL不支持Linux,那么咱就用开源的MySQL.
-----------------------------------------------------------------------------------------------------------------------------
利用apt-get进行安装配置.确保你的source.list是能够下载到资源的.不要用网易的源...(当然如果你翻墙的话,一切都会变得很美好,简单)
命令行键入以下指令
sudo apt-get install mysql-server mysql-client #中途会让你输入一次root用户密码
sudo apt-get install php5-mysql #安装php5-mysql 是将php和mysql连接起来
然后一切都OK了,只是中间会让你设置一个账号密码,反正自己记住就是啦~无碍.
之后mysql服务就自动开启了,之前我还不知道.后来还傻乎乎的去关闭了再打开...
sudo start mysql #手动的话这样启动
sudo stop mysql #手动停止
确保想要进行数据库操作的时候,mysql server是打开的.
如果和我一样对MySQL语法不熟悉的话可以去下面这个站点"现学现卖"
http://www.w3cschool.cc/mysql/mysql-select-query.html
demo:
比方说我们想...
创建如下表的SQL语句,要求在定义表的同时定义数据的完整性约束:
“图书表”结构如下:
书号:统一字符编码定长类型,长度为6,主码;
书名:统一字符编码可变长类型,长度为30,非空;
第一作者:普通编码定长字符类型,长度为10,非空;
出版日期:小日期时间型;
价格:定点小数,小数部分1位,整数部分3位。
根据这样的要求,我们可以
至此,我们就进入mySQL的环境啦.
创建表,别急...首先我们得创建个数据库...
利用命令
create databases 数据库名称;
我们创建了一个名叫jason的数据库,我们还可以查看当前SQL在当前账户管理下有哪些数据库存在着
如图利用show databases命令.
我们发现除了我刚才创建的名叫jason数据库之外,还有其他的数据库,比方说test.
我们要创建表,首先要进入我们想要在哪儿数据库内建立表的那个数据库
利用
use 数据库名;
命令进行切换
可以由上面的截图看到,我们可以如何创建一个名叫books的表.这样,我们的表就建好了.
接着我们要做的就是为这张表格补全信息,并对这张表进行操作.
插入某一本图书的信息,比方说"The C language"
上面我们插入了所有能够插入的信息(book_number,book_name等我们为books表格定义的列信息),我们都用到了.如果有些时候我们不需要插入这么多信息,我们可以通过第二个参数列表来控制,即减少第一个括号里面的信息.如下:
第一个括号的信息总是和第二个括号对应的.
我们通过select命令查看当前都有哪些书籍了
啊哈,我们插入的信息都在这里,整理的很好
当我们只需要知道书名的时候,我们可以这样利用select
之后我又为我的表格添加了一些信息.现在表格里已经存放了如下信息
我们想挑出价格在80元以下的书籍,怎么办呢?
这样,我们就正确的挑出了价格在80以下的书籍.
如果想学习更多MySQL的语法命令,可以去下面的link.
http://www.w3school.com.cn/sql/sql_distinct.asp
MySQL与SQL语法相近,而MySQL开源,I ask you that why not MySQL?!
知行合一

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings

The methods for viewing SQL database errors are: 1. View error messages directly; 2. Use SHOW ERRORS and SHOW WARNINGS commands; 3. Access the error log; 4. Use error codes to find the cause of the error; 5. Check the database connection and query syntax; 6. Use debugging tools.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.
