Mysql Database
Mysql database: Essentially a software for storing and managing files
So for MySQL, there are two of software:
--Server Software:
Socket Service Side
Local file operations
--Client software:
Socket Client
Send instructions
Parsing instructions (MySQL statement)
For the server software in the socket server is always open, the client needs to connect at any time, as well as create files, delete files, and other operations.
For the socket client in the client software, we need to send instructions to command the socket server file for operation.
MySQL skills to master (content):
--Installation Server (MYSQLD) and client (MySQL)
--Connection
--Learn the rules of the SOL statement; command the server to do any action
Database definition: The warehouse where the data is stored. A database is a data that is stored in a computer, organized, and shared over a long period of time.
The data in the database is organized, described and stored in a certain data model, which has smaller redundancy, higher data independence, and can be shared by data.
Database management systems (DB Management System):
Classification of database management software
There are two main categories: relational: Like Sqllite,db2,oracle,access,sql server,mysql, Note: SQL statement general non-relational: Mongodb,redis,memcache can be simply understood as: Relational database requires a table structure non-relational database is Key-value stored, no table structure
A non-relational database is stored in the same way that the key corresponds to the value.
Database server, data management system. Database.. Table-to-record relationship:
Record: 1 xxx 324245234 22 (Multiple fields of information form a record, that is, a line of content in a file)
Table: student,scholl,class_list (i.e. file)
Database: Oldboy_stu (that is, folder)
Database management system: such as MySQL (is a software)
Database server: One computer (high memory requirements)
Summarize:
Database server-: Running database management software
Database management software: Management-Database
Database: A folder for organizing files/tables
Table: A file that is used to hold multiple lines of content/Multiple records
Mysql is installed in basic management:
To add an environment variable:
【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行,双击】 --> 【将MySQL的bin目录路径追加到变值值中,用 ; 分割】
5. Initialization
1 |
mysqld - - initialize - insecure |
6. Start the MySQL service
MYSQLD #启动MySQL服务
7. Start the MySQL client and connect to the MySQL server (a new CMD window is opened)
Mysql-u root-p # Connect to MySQL server
The last step solves some problems, but is not thorough enough, because the current terminal will be stuck when executing "MYSQD" to start the MySQL server, then do the setup to solve the problem, the MySQL service will be made into a Windows service
Note: Before--install, you must use the absolute path of the MySQL startup command # to make the MySQL Windows service, execute this command at the terminal: "C:\mysql-5.6.40-winx64\bin\mysqld"--install# Remove the MySQL Windows service and execute this command at the terminal: after the "C:\mysql-5.7.16-winx64\bin\mysqld"--remove is registered as a service, the MySQL service can be started and shut down at a later time, only the following commands are executed: # Start MySQL service net start mysql# shut down MySQL service net stop MySQL
Windows logon Settings password
Open terminal, enter MySQL
Enter the functions provided by MySQL: Select User (); # view currently logged in account
The default account for the current login is [email protected]
If you want to log in to the root account
Execute command:
Mysql-uroot-p
Then view the current User:
Select User ();
Administrator for Root (with the highest privileges, Administrator account), password is empty, password -free way to login to the administrator account, is a very dangerous thing, so to set a password for the Administrator account
Set the administrator root account password to 123
C:\users\mjj>mysqladmin-uroot-p password "123" #设置初始密码 because the original password is empty, so-P can not
Ps:?? Don't care about it. The password is not secure at the command line interface and is exposed to the terminal.
Then login to the account, do not enter the password will appear the following results:
Perform the following actions again:
Then check the current login account:
If you want to have the original password 123, set the new password to 456
C:\users\mjj>mysqladmin-uroot-p "123" password "456" #修改mysql密码, because there is already a password, so you must enter the original password to set a new password
Perform the following operations in turn:
Mysql-uroot-p456select user ();
Password forgot--crack password
Skip the authorization method and log in directly!!
0. Open cmd as Administrator
2. Stop the MySQL server
C:\windows\system32>net Stop Mysqlmysql service is stopping. The MySQL service has stopped successfully.
3. Execute the following command to skip the authorization form
#跳过授权表C: \windows\system32>mysqld--skip-grant-tables2018-06-09 17:12:38 0 [Warning] Insecure configuration for-- Secure-file-priv:current value does not restrict the location of generated files. Consider setting it to a valid, Non-empty path.2018-06-09 17:12:38 0 [Note] mysqld (mysqld 5.6.40) starting as Process 605 2 ... 4.
4. Check Again
5. Now you can change the password arbitrarily, execute the following command
Update Mysql.user set authentication_string =password (") where user= ' root ';
6. Refresh permissions, execute commands
Flush privileges;
7. Quit MySQL. Execute command: Exit,
8. Let the user go to load permissions, enter CMD as administrator to view the current MySQL process
1 |
tasklist |findstr mysql #查看当前mysql的进程 |
9. Kill the current process and execute the following command
taskkill/f/pid 6052 # kills the current process PID
10. Perform the following actions again to restore
Unified character encoding
Go to MySQL client and execute \s
To unify character encoding, do the following:
(1) The My.ini file is a MySQL configuration file,
Create a My.ini file under the C:\mysql-5.6.40-winx64 file
(2) Save the following code copy.
#mysql5.5 or more: Modified by [mysqld] Character-set-server=utf8 collation-server=utf8_general_ci [client] Default-character-set=utf8 [MySQL] Default-character-set=utf8
(3) Restart the service as an administrator and execute the following command
C:\windows\system32>net Stop Mysqlmysql service is stopping: The MySQL service has stopped successfully. C:\windows\system32>net Start Mysqlmysql service is starting. The MySQL service has started successfully.
(4) Enter MySQL in cmd to enter MySQL environment, execute \s, display the following information, indicating success
Note: \c indicates that the previous line of code is not executed;
Content supplement:
Process-Related:
--View process:
tasklist | findstr MySQL
--Close the process:
taskkill/f/pid Process Number
MySQL Database First day