MySQL is a simple and easy-to-use basic operation guide. (1) Introduction to mysql basic operations
System: Ubuntu 14.04 LTS
Installation:
Apt-get install mysql // install the database apt-get install mysql-workbench // install the graphical interface
Usage:
At startup: mysql-h [address]-p [port]-u [user name]-p [Password]
It will be like this:
Mysql> is the place where the command is input. to exit, use exit.
In mysql, commands generally require extra points.
Database Operations:
Create database name; create show databases; view drop databases; Delete use database Name; use the current database
Table operations:
Show tables; view table create table (extra parameter for column name data type,...); create table
Common additional parameters:
NULL/NOT NULL
DEFAULT
AUTO_INCREMENT auto-Increment
UNIQUE
Parmiry key primary KEY
Foreign key (this is different from SQL Server)
Constraint foreign key (KEY name) REFERENCES (KEY name)
Character set (garbled characters may occur if not set)
CHARSET = UTF-8 /.....
The operation on the table itself is the same as that on the standard SQL language.
Mysql basic statements
According to their online data, they are all written in the same way. At the same time, many of them are not well written. The following is my summary of mysql usage details, it is also some of my records in the learning process. I hope it will be helpful to you. I have not summarized the stored procedure and other related operations. I will give it to you next time, haha ~~~~~
MySql Study Notes
MySql Overview: MySql is an associated database management system. The so-called associated database stores data in different tables, rather than placing all the data in a large warehouse. This increases the speed and flexibility. MySql is an open source software.
Note: The maximum TimeStamp range supported by MySql is that on 32-bit machines, the supported value range is that the year should not exceed 2030. If the value is on a 64-bit machine, the year can reach 2106, but for date and datetime types, there is no relationship between them. They can all be expressed as 9999-12-31, so pay attention to this. Also, when installing MySql, we generally choose Typical (Typical installation). Of course, if there are other purposes, we 'd better choose Complete (full installation ); during the installation process, you are usually asked to select the Server type. There are three Server types, Developer and Server Machine), Dedicated MySql Server Machine (Dedicated MYSQL Server), select which type of Server will only affect the Configuration Wizard on memory, or other aspects will have no impact; therefore, if we are a developer, you can select the development machine. Then, you can select the database usage dialog box by default;
Connect to and disconnect the server:
Connection: enter a command set similar to the following at a windows Command Prompt: mysql-h host-u user-p
For example, when I use mysql-h localhost-u root-p
Then you will be prompted to enter the user password. At this time, if you have a password, enter the password and press Enter. If there is no password, press enter to access the database client; to connect to mysql on the remote host, run the following command: mysql-h 159.0.45.1-u root-p 123
Disconnect the server: after entering the client, you can directly enter quit and press Enter;
The following describes database commands.
You can enter the following command to perform related operations on the database table or database, which is omitted here and then directly explained in text;
Select version (), current_date; // obtain the current mysql version and date from the server.
Select user (); // obtain all users of the current database
Use databasename; enter the specified database, and then you can operate the tables in the database.
Show databases; // query all databases in the current database and display them;
Create batabase databasename; create a database, for example, Create database manager;
Show tables; // view all tables in the current database;
Create table tablename (colums); create a table and specify related columns for the table, for example, Create table pet (name varchar (20), owner varchar (20 ), species varchar (20), sex char (1), birth date, death date );
Describe tablename; display all the information in the table in detail, for example, descr ...... remaining full text>
Php mysql Code help, a newcomer with super simple code, let's take a look,
Paste the code.