Introduction to...LOGIN

Introduction to PHP MySQL

PHP MySQL Introduction

Through PHP, you can connect and operate the database.

MySQL is the most popular open source database system used with PHP.

If you want to learn more MySQL knowledge, you can check out the MySQL tutorial on this site.

What is MySQL?

· MySQL is a database system used on the Web.

· MySQL is a database system that runs on a server.

·                                                                                                                                       MySQL is an ideal choice for both small and large-scale applications.

·                  MySQL is very fast, reliable, and easy to use.

· MySQL supports standard SQL.

·                     MySQL is compiled on some platforms.

· MySQL is free to download and use.

· MySQL is developed, published and supported by Oracle Corporation.

· MySQL is named after the company founder Monty Widenius's daughter: My.

The simple understanding of database is: a warehouse used to store and manage data

Databases can be divided into relational databases and non-relational databases according to their design principles:

• In the current course, we mainly focus on the relationship -type database MySQL

• The final course, we will learn non -relational database mongodb

## Relationship database:

We are learning Through a two-dimensional array, when we print the league points table, we actually output the data of a two-dimensional array. In fact, the two-dimensional array is the most intuitive way to store data. Key, easy access

•                                                                                                                                                                        的 的 综合是综合的狠 狠 ‑‑            There can be any number of rows of data, and a large amount of data can be saved

The design of relational data adopts the concept of two-dimensional arrays. Therefore, the so-called relationship is actually a two-dimensional table, and a relational database is a data warehouse composed of a set of two-dimensional tables

Our common ones: MySQL, Oracle, SQLServer, Sqlite, etc. are all relational database software

Basic terminology

We have the following terms in relational databases:

• Data table: Each two-dimensional table is a data table, which represents a relationship, so it must There is a relationship name, which we call the table name

•   Record: A row in the two-dimensional table is called a record

•   Field: A column in the two-dimensional table is called a field

Database: a collection of data tables

##Distinguish between database and database software

We usually call Oracle or MySQL a database. In fact, the full name should be database management software, and the collection of data tables is called a database.

Therefore, one database management software can manage multiple databases, each There can be multiple data tables in the database, and multiple fields can be set in each data table.

QQ图片20161009165312.png

Data in MySQL is stored in tables. A table is a collection of related data, consisting of columns and rows.

Databases are very useful when storing information in categories. A company's database may have the following tables: The role on

PHP + MySQL

· The combination of PHP and MySQL is cross-platform. (You can develop on Windows and apply on Unix platforms.)

Query

A query is an inquiry or request.

QQ图片20161009165326.pngThrough MySQL, we can query the database for specific information and get the returned record set.

Please see the following query (using standard SQL):

mysql> set names utf8;
mysql> SELECT name FROM websites;
+---------------+
| name          |
+---------------+
| Google        |
| 淘宝        |
| PHP中文网 |
| 微博        |
| Facebook      |
| stackoverflow |
+---------------+

6 rows in set (0.00 sec)

The statement set names utf8; is used to set the database encoding, Allow Chinese to be displayed normally.

The above query selects all the data in the "name" column in the "websites" table.

To learn more about SQL, visit our SQL tutorial.

Download MySQL database

If your PHP server does not have a MySQL database, you can download MySQL for free here: http://www.mysql.com.

Using MySQL

The MySQL database has been installed in your WAMP and can be used directly. The default port of MySQL is 3306. The default user name of WAMP is root and the password is empty.

WAMP also comes with a software called phpmyadmin by default, through which we can manage and operate the database.

Although most database operations can be completed through phpmyadmin, a qualified PHP must at least know some basic database command line operations

Open the WAMP menu to enter the MySQL console

Login to MySQL

When using the MySQL console, you only need to enter the password directly (the default password is empty, just press Enter) to log in

In actual circumstances, to log in to MySQL, you need Execute the following command on the command line

dos D:\wamp\bin\mysql\mysql5.6.17\bin

mysql –h hostname –u username –p

-h h is the abbreviation of host, indicating the server address where the current database is located, which can be a domain name or IP

-u u is the abbreviation of username, indicating the username

-p means password

After executing the above command, you will be asked to enter the user's password. If it is empty, you can press Enter directly, or do not add the -p parameter

Built-in database

Already exists in the newly installed MySQL There are 4 databases

show databases;

•                                                                                                          with with with with with with--

• Mysql manages the user account and other information of the database

• test is an empty library provided to developers for testing

Just like our Windows system files, these four libraries, except Except for test, none can be deleted

Facts about the MySQL database

One of the great features about MySQL is that it can be reduced to support embedded database applications. Perhaps because of this, many people think that MySQL can only handle small and medium-sized systems.

In fact, MySQL is the de facto standard database for those websites that support huge data and traffic (such as Friendster, Yahoo, Google).

This address provides an overview of companies using MySQL: http://www.mysql.com/customers/.

Next Section
submitReset Code
ChapterCourseware