In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to log in to mysql database". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to log in to mysql database.
As we all know, there are many ways to log on to the mysql database. Here we will introduce several ways to log in to the mysql database by Xiaobian, which can be referenced by those who need it.
Several ways to log in to mysql database
The first (through mysql's native client, MySQL 5.5Command Line Client) is not recommended
Note: this login method is only applicable to root users and is not flexible enough! (it is only suitable for root users, but only for root users. In the future, we may have many other users, so other users will not be able to log in in this way, so there are limitations in logging in to mysql database in this way.) therefore, it is not recommended to log in to mysql database in this way.
To log in, use the exit command or ctrl + c as shown below:
The second (using the dos command window of windows and the mysql command) recommends this method, as shown in the screenshot below:
Win + r
Enter cmd again
As shown below: enter the command mysql-h localhost-P 3306-u root-proot in the dos window
Next, I'll explain the mysql command in detail.
Mysql-h localhost-P 3306-u root-proot
(1.) the first mysql can be understood as a keyword or a fixed command, which is written in a fixed way, similar to the javac command or java command in java or jdk
(2.)-h indicates host, that is, the ip address of the host
(3.)-P means port, port, the default port for mysql database is 3306, of course, you can change the port number yourself, I did not change the port number here (note: this is the capital letter P)
(4.)-u indicates user user name
(5.)-p represents the password password (note: this is the lowercase letter p)
Here are the considerations for the mysql command:
The uppercase P indicates the port number, and the lowercase p indicates the password.
We should remember that the lowercase p indicates the password, and there must be no space between-p and the password. Other things, such as-ujingliehlippi p and so on, can have or without spaces.
Note: if it is local, the host ip and port number can be written as mysql-u root-proot without writing (that is, the host ip and port number can be omitted).
If it is local, but you have changed the port number to another port number, which is not the default 3306. For example, if you change the port number to 6688, add the port number, that is, mysql-P 6688-u root-proot.
The following three grammars are correct. I will demonstrate them with examples and screenshots in turn.
The user name I use here is root, and the password is root.
Syntax 1:mysql-h host ip address-P port number-u user name-p password (space between-h and host ip address, space between-P and port number, space between-u and user name, there must be no space between-p and password)
Mysql-h localhost-P 3306-u root-proot
If it is local,-h localhost-P 3306 can be omitted and written as mysql-uroot-proot or mysql-uroot-proot.
Or
Mysql-h 127.0.0.1-P 3306-u root-proot
Or
Mysql-h 192.168.117.66-P 3306-u root-proot (to connect to a remote host, you must write the ip of the remote host)
If the mysql database port of the remote host is 3306 by default, the port number can be omitted, but the ip address of the remote host should be written.
Mysql-h 192.168.117.66-u root-proot
If the mysql database port of the remote host is changed to, for example, 6655 instead of the default 3306, the ip address and port number of the remote host should be written down.
Mysql-h 192.168.117.66-P 6655-u root-proot
If it is local, the host ip address and port number (default 3306) can be omitted.
Mysql-uroot-proot or mysql-uroot-proot
If it is local, the host ip address can be omitted, or the port number can be written.
Mysql-P 3306-u root-proot
If it is local, the port number can be omitted or the host ip address can be written.
If it is local, but you changed the port to something else before, for example, if you changed the port to 8801, instead of the default port 3306, then the host ip address can be omitted, but the upper port number should be written.
Mysql-P 8801-u root-proot
The order of parameters does not matter, and-h and-P can also be placed at the end, as follows
Mysql-u root-proot-h 192.168.117.66-P 3306
Syntax 2:mysql-h host ip address-P port number-u user name-p password (no space between-h and host ip address, no space between-P and port number, no space between-u and user name, no space between-p and password)
Mysql-h292.168.117.66-P3306-uroot-proot
Syntax 3:mysql-h host ip address-P port number-u user name-p (last-p, no password is written after the lowercase p)
Mysql-h 192.168.117.66-P3306-uroot-p or mysql-h292.168.117.66-P3306-uroot-p
As shown below: the password is not written after the lowercase letter p, so that the password will not be exposed, and the password will be displayed as * when entering the password.
If we write the password after the lowercase p, the password is displayed, as shown below:
I warn you, the password is not safe.
Mysql: [Warning] Using a password on the command line interface can be insecure
Enter the password on the command line and you will be prompted with these security warnings
Let's take a look at what the wrong way of writing is.
Some people write mysql-h 192.168.117.66-P 3306-u root-p root Note: there is a space between the small p and the password, which is incorrect, as shown below:
Some people write mysql-h 192.168.117.66-P 3306-u root Note: write less-p (small p), this method is also wrong, as shown in the following figure:
We according to the specific actual situation, flexible use of mysql commands!
In a word, small p means password. There must be no space between small p and password. Other parameters-u,-h,-P (uppercase P), etc., can have or without spaces.
If you are afraid that you will forget that there must be no space between the small p and the password, then write all the parameters without spaces, so that it is not easy to make mistakes. If you write it uniformly as mysql-h292.168.117.66-P3306-uroot-proot, it will be ok, as shown below:
To log out, you can use the exit command
Note: the keyword mysql is a command in the mysql database, not the dos command that comes with the windows operating system, just like the two keywords javac and java, javac and java are the commands that come with jdk, not the dos commands that come with the windows operating system. It is also important to say that the two commands javac and java can be executed under any path in the dos window. Because the environment variables of java and JDK are configured in the windows operating system!
If you find that you cannot execute the mysql command when you execute the mysql-h localhost-P 3306-u root-proot command, you can take a look at the environment variables in windows and see if there are environment variables that configure the mysql database.
I automatically configured the environment variables of the mysql database when I installed the mysql database! If you do not configure the environment variables of the mysql database, you can match it yourself, of course, you can not match it. If you want to use the mysql command, in the dos window, first change to the bin directory under the installation path of the mysql database, and then execute the mysql command. In this case, it is troublesome to change to the bin directory where the mysql database is installed every time, and then execute the mysql command. Therefore, it is recommended that friends configure the bin directory where the mysql database is installed into the environment variables in the operating system, so that it is very convenient to use the mysql command!
As shown below: this is the configuration when I installed the mysql database
You can also set the configuration of the mysql database. Double-click MySQLInstanceConfig.exe in the bin directory where you installed the mysql database, as shown below:
Or you can configure environment variables directly in windows
Under normal circumstances, there is no problem.
If there is a problem, put the sentence D:\ Software\ mysql5.5\ bin first, followed by a semicolon, which is similar to the environment variable for configuring java, as shown below:
After configuring the environment variables of the bin directory of the mysql database, close the original dos window and reopen a dos window and enter the mysql-h localhost-P 3306-u root-proot command.
How do we log out if we want to log out of the mysql database? Enter exit and enter enter.
Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.