Chapter 1 first MySQL
1-1mysql Overview
installation and configuration of 1-2mysql
1-3 start and stop MySQL service
1-4 Landing and exit
1-5 modifying the MySQL prompt
1-6 modifying MySQL common commands and syntax specifications
1-7 Operating Database
1-1mysql Overview
MySQL Database
MySQL Basics
Install MySQL
Configure MySQL
Using MySQL
MySQL Basics
MySQL was developed by the Swedish MySQL AB Company and currently belongs to Oracle.
MySQL is an open-source relational database management system.
MySQL is divided into Community Edition and Enterprise Edition.
installation and configuration of 1-2mysql
Install MySQL
MySQL Installation Method:
MSI Installation (Windows Installer)
ZIP Installation
MIS Installation Method:
Double-click the MSI installation file
The end-User License Agreement
Select the installation type
Typical: A typical installation has its client installed in addition to the server
Custom: Customized Installation
Complete: Fully installed
Prepare the installation .
Installation Progress
06.MySQL Product Advertising
07.MySQL Product Advertising
ask if you want to configure the operation.
Configure MySQL
Run the MySQL Configuration Wizard file
/bin MySQLInstanceConfigur.exe
The Configuration Wizard Welcome Interface
A. Select a configuration type
Detailed configuration details
Standard configuration
whether to install as a Windows service
Install as Windows service
The default name is MySQL
Launch the MySQL Server automatically
Automatically run MySQL service Every time the computer starts
Include Bin Directory in Windows PATH
Add the \\bin to the environment variable.
set The password security settings for the root user .
. preparing to perform setup options
. configuration Complete.
MySQL directory Structure
Bin Directory, storing executable files
Data directory, storing the file
Docs directory, documentation
Include directory , which stores the included header files
Lib directory, repository file
Share directories, error messages, and character set files
configuration options for MySQL
Modifying the Encoding method
Modify in My.ini
[Client]mysql default port port=3306;
[MySQL] Default encoding Method GBK can be modified to UTF8 ,
Default-character-set=utf8;
[Mysqld] mainly in MySQL server-side configuration,
Port port3306,
Basedir refers to the basic installation location of MySQL,
DataDir refers to the location of the data directory,
Character-set-server=utf8 refers to the encoding of data stored on the current server;
1-3 start and stop MySQL service
Two of the most common:
One is the graphical operation, on the basis of the operating system, open the Computer Management, in the service, right-click MySQL to start or stop.
The other is command-line operations (note: At the command prompt, it is best to run under administrator privileges, especially during the configuration of the ZIP installation process.) ),
Start MySQL service:net start MySQL (Note: If the startup error is noted, the service has started.) ),
Stop MySQL service:net stop MySQL
(net start and net stop is a service that starts and stops service commands that can be used to start other services in the list of services in the previous operation.) )
1-4 Landing and exit
the use of the MySQL service requires logging into the MySQL client, which can be used by sending some execution instructions from the client to the server for MySQL .
Using MySQL
MySQL Login / logout
Modify the MySQL prompt
MySQL Common Commands
MySQL Statement Specification
Database operations
MySQL Login
MySQL parameters
Parameters:
-D,--database=name Open the specified database
--delimiter = name Specifies delimiter
-H,--host=name server name
-P,--password[=name] password
-P,--port=# Port number
--prompt=name Setup Prompt
-U,--user=name user name
-V,--version output version information and save exit
(Enter at the command line)
Eg.mysql-uroot-p ( password, you can also do not fill in the system prompt input )-p3306(port number generally does not change) - H ( local IP address )
MySQL Exit
In mysql > under Input
Exit
Quit
\q;
1-5 modifying the MySQL prompt
Prompt: mysql>
There are two ways to modify:
Modify the MySQL prompt
When connecting to a client (referring to a login) by specifying parameters
Shell>mysql-uroot-proot--prompt Prompt
Eg.mysql-uroot-proot--prompt \h prompt changed from mysql> to localhost
After connecting the client, modify the prompt command by using the
Mysql>prompt Prompt
What parameters can the prompt follow? :
\d Full Date
\d Current Database
\h Server name
\u Current User
eg. PROMPT set to ' \[email protected]\h \d> '
Use text; then look at the name of the prompt.
1-6mysql Common commands and syntax specifications
MySQL Common commands:
SELECT VERSION (); Displays the current server version;
SELECT now (); Displays the current date and time;
SELECT USER (); Display the current user;
specification for MySQL statements:
Keywords and function names are all capitalized (although the system can still be recognized when lowercase, but still capitalized for clear recommendations for the specification and operation of a code);
Database name, table name, field name all lowercase;
The SQL statement must end with a semicolon;
1-7 Operating Database
More is to do some basic management of some databases.
MySQL is installed and comes with 4 databases:information_schema,mysql, Performance_schema , Test .
Database operations:
Create a database
CREATE {DATABASE | SCHEMA} [IF not EXISTS] db_name [DEFAULT] CHARACTER SET [=] Charset_name
{} is required | is to make a choice from several items. [] is optional
DATABASE and SCHEMA are the same;
If not exists warnings show warnings to view the error message, including the level of the error message () error code ( ) error message ( )
The CHARACTER SET is the encoding of the specified database, which is the default encoding for mysql by default. SHOW CREATE database table_name (t1); the encoding of the databases can be modified.
eg. The CREATE DATABASE t1;// syntax is the same as before.
1 row affected.// because when you create a database to save it to the server, 1 rows are affected.
View a list of data tables under the current server
SHOW {DATABASES | SCHEMAS} [like ' Pattern ' | WHERE Expr]
Modify Database
ALTER {DATABASE | SCHEMAS} [Db_name] [DEFAULT] CHARACTER SET [=] Charset_name
Deleting a database
DROP {DATABASE | SCHEMA} [IF EXISTS] Db_name
Creation under if EXISTS and if not EXISTS is similar.
Query and find are different!!! Detailed explanation later in the essay.
1th. mysql in the first chapter