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











MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

Redis is a memory data structure storage system, mainly used as a database, cache and message broker. Its core features include single-threaded model, I/O multiplexing, persistence mechanism, replication and clustering functions. Redis is commonly used in practical applications for caching, session storage, and message queues. It can significantly improve its performance by selecting the right data structure, using pipelines and transactions, and monitoring and tuning.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.
