The use of MySQL - [First Understanding MySQL] Section 2
Article directory
Configuration of MySQL environment variables (negligible if using Navicat)
Search and edit system environment variables
Click on Environment Variables
Create a new variable and value as shown in the figure in the system variable
Select the Path path in the system variable, click Edit, and add the following statement
Click OK continuously to complete the environment variable configuration. (If you use Navicat below, whether the environment variable is configured or not has little effect)
Use the command line to connect to MySQL (if you use Navicat, you can ignore it)
step
mysql -u root -p
The following command means to use the root user (mysql root user, non-system root user) to connect to the mysql database, -u means to specify the user, -p means to prompt for a password, and the space between -u and the root user name can be omitted. (Must be in the correct folder to successfully implement this command)
Open DOS as administrator (win+r; type cmd; press Ctrl+shift+enter at the same time)
Find the bin folder, copy
C:\Program Files\MySQL\MySQL Server 5.7\bin
Enter the following command in DOS
cd /D C:\Program Files\MySQL\MySQL Server 5.7\bin
Enter after the carriage return:
mysql -u root -p
If the following interface appears, it is successful
2. The following command indicates that the root user is used to connect to the database, and the password is specified directly in plain text. Note that the password in the following example is 123123, and there must be no spaces between the password and the -p option.
mysql -u root -p123123
3. When connecting to mysql, you can directly specify the specific database to be logged in, and use -D to specify the database name. The following command means to use the test database directly after connecting to the mysql database.
mysql -u root -D test -p123123
4. When connecting to mysql, you can specify the mysql of the remote host to connect to, or you can specify the port, -h specifies the mysql host, -P is capitalized, and specifies the port corresponding to the mysql service. The premise of the connection is that it has Authorizes the current client's IP address to be able to connect to the database.
mysql -u root -p -h 192.168.1.103 -P 3306
5. Execute the corresponding command while connecting to the database, and return the result corresponding to the command, and will not enter the mysql prompt.
The example is as follows, which means that while connecting to the database, execute the sql statement following the -e option, and return the result of the statement execution.
mysql -u root -p123123 -e 'use mysql; select user,host,password from user;'
mysql -uroot -p123123 -e 'create database if not exists testdb; show databases;'
Notice
Make sure the MySQL service is started before connecting
Navicat
Download Navicat
Navicat Introduction: Graphical MySQL Management Software
I shared "Navicat_Premium_11.0.17_XiaZaiBa.exe" with the quark network disk, click the link to save it. Open "Quark APP", no need to extract the code.
Link: https://pan.quark.cn/s/9dc0c795f81f
Use of Navicat
connect to mysql
1. Open Navicat
2. Click Connect
3. Select MySQL
4. Correctly fill in the following content
My port number has been changed from 3306 to 3307, remember to fill in 3306 if it has not been changed
new table
Use Navicat to create a database student, and create a table named user in student.
Right click and select New Database
Fill in the following options
After confirming, select the table, right click and select New Table
Define table properties
Note that the id option selects auto-increment (the id value can be automatically assigned to the content of the table later), and the content of the first row needs to click on the primary key (yellow key symbol).
Perform the save operation Ctrl+S , and name the table user
Finally, click user and fill in the data in the form.
Congratulations, now you have mastered the steps of using Navicat! ! !
Summarize
The configuration of MySQL environment variables does not affect the use of MySQL in Navicat;
MySQL is similar to a library for storing and storing data;
Navicat is similar to a librarian, it can help users operate and use data in MySQL intuitively and conveniently.
r)
Congratulations, now you have mastered the steps of using Navicat! ! !
Summarize
The configuration of MySQL environment variables does not affect the use of MySQL in Navicat;
MySQL is similar to a library for storing and storing data;
Navicat is similar to a librarian, it can help users operate and use data in MySQL intuitively and conveniently.