1. The installation of MySQL
Many of them are recommended to install on the MySQL website. When I first tried it, I downloaded a zip file from the MySQL website. When I opened it, I couldn’t find it at all
Address: dev.mysql.com/downloads/w…
Once installed, you’ll see one of these files
First of all you have before installing
You can’t install it without it, you can download it here
Support.microsoft.com/zh-cn/help/…
Install MySQL
Because I have installed version 8 here, so the display is gray, it must be clickable without installation
I’m assuming version 5.7 is installed here
Click where I marked to configure the directory
After that, it is basically simple, all the way to next(there is a point to register the user name and password, this is to configure yourself).
Just remember that MySQL’s default port number is 3306
Usually we don’t make modifications
Finally, configure the environment variables
The installation is ready to enter at the terminal
mysql --version
Copy the code
If the version is displayed, the installation is successful
2. Connect and disconnect MySQL
1. Connect to the MySQL server
-h Indicates the host address
-p port number
-u username
-p Indicates the user password
I only have a computer here, I will connect to the local IP address, the future development is definitely connected to the server of MySQL
Mysql - h127.0.0.1 - P3306 -uCopy the code
Pay attention to the point
If the MySQL server is local, the host address can be omitted
If the server uses the default port 3306, the port number can be omitted
My username and password are both root.
mysql -uroot -proot
Copy the code
But generally speaking input password should not let it display, so use the way of dark text to type *
mysql -uroot -p
Copy the code
However, this is not the final solution, because AS I said, MySQL is usually on the server, so we test on the local, so the host address is not omitted, the port number is generally the default
So the ultimate order is
Mysql - h127.0.0.1 - uroot - pCopy the code
But when I started using it, THERE was a bug, which caused me to search a lot of baidu for a long time
Finally, I did my own research and found the bug
Don’t commands usually strike at the terminal
If you’re tapping on the global terminal
Mysql - h127.0.0.1 - uroot - pCopy the code
This ultimate order will not work
It will give you the wrong, say what the host 127 address no yapping, carefully actually look here
You’ll see the downside
Why is 127 black and 0.0.1 white behind it
And then I try to separate it
Mysql -h 127.0.0.1 -uroot -pCopy the code
In this way, the MySQL service will connect successfully
But I can run it by typing the terminal command in the editor
Mysql - h127.0.0.1 - uroot - pCopy the code
And why? I don’t know for sure
Anyway, I stepped on this hole, so no one will step on it
2. Disconnect the device
exit;
quit;
\q
Of course, the simplest and most useful ah, so I choose \ Q
3. The database is displayed
show databases;
Copy the code
information_schema
Holds information about all other databases maintained by the MySQL server. Such as database name, database table, table column data type and access permission
mysql
MySQL system database, which stores the login user name, password, and permissions of each user, etc
Performance_schema (may be able to do this)
The parameters used to hold database server performance
sys
The library combines information_schema with Performance_schema in the form of views to query for more understandable data
4. To summarize
Connecting to a Database
Mysql -h127.0.0.1 -u User name -pCopy the code
disconnect
\q
Copy the code
Display database
show databases;
Copy the code