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)06/01 Report--
Editor to share with you how to use the command to install mysql in cmd. I hope you will learn a lot after reading this article. Let's discuss it together.
Methods: 1, download the package on the official website, and extract it to the specified directory; 2, create a configuration file named my.ini; 3, open the command line window as an administrator, and change the directory to MySQL's bin directory; 4, execute the "mysqld install MySql Service name" installation command, and then initialize it.
Download the compressed package
Description: under Windows, install MySQL can download the installation package directly (download address: https://dev.mysql.com/downloads/installer/), and then directly follow the prompts of the installation package to install the functions you need. You can also download the zip package directly. The package contains only the basic files needed by the MySQL server and has no visual graphical interface (download address: https://dev.mysql.com/downloads/mysql/). This article describes how to install MySQL through the installation package (Community Edition: 8.0.12).
II. Installation of MySQL services
Decompress the package
After decompressing the package, you can see the following files and folders:
Description: there is no data directory or .ini type configuration file in the extracted files and folders. The configuration file is used to configure some basic information about the MySQL server, including the port at startup, and the data directory is used to store the database of the MySQL server.
Installation service
If you don't have a configuration file, you can create your own configuration file named my.ini.
Open the command line window as an administrator (be sure to use the administrator's identity), and change the current directory to the bin directory of MySQL (the previous bin directory, where the unzipped folder is placed does not matter). Execute the installation command:
Mysqld install MySql80
To uninstall a MySql service, you can use the following command:
Mysqld remove MySqll80
Note: the following MySql80 is the name of the MySql service, which you can specify yourself. If you want to install multiple MySql services on a single machine, the names of the services must be different.
Initialization
After installation, you need to initialize it with the following command:
Mysqld-initialize-console
-- console is used to output some information during initialization, and you can see some basic information during initialization. In the output information, you can find the following statement: you can see that the user name of the account is root and the password is a randomly generated string.
A temporary password is generated for root@localhost: JmurWh6 submission = in the statement entered later, the semicolon (;) is the default submission symbol. When you press enter, you will only wrap, and the statement will not be submitted. Then enter; then press enter before the statement will be submitted.
If the-- initialize-insecure command is used for initialization in front of mysql, the password is empty, and you can press enter directly when entering the password. After logging in, you can use MySQL directly without changing your password. For example: create a database and other operations. If the-- initialize command was used to initialize the mysql, the password is a string randomly generated by the system. You need to change your password before you can use it after logging in.
If you directly manipulate the database without changing the password, the following error will occur:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Use the following command to change the password:
Set password='new_password' Note: the new password is enclosed in single quotation marks. In mysql, a string is represented between single quotes.
The alter user 'root'@'localhost' password expire never; setting password never expires.
Flush privileges refresh permissions.
Then log out (use\ Q, or either exit or quit), and then log in again.
At this point, you can use MySQL normally.
3. Installation of multiple MySQL
If you want to install multiple MySQL services on one machine. You can copy the previously unzipped folder to another directory (note: data needs to be empty, otherwise it cannot be initialized). Then follow the previous steps to install the MySQL service. The following are the things to be noted:
The names of multiple MySQL services cannot be the same. The port number of multiple MySQL services that cannot be successfully installed at the same time cannot be the same (the port number can be configured in the configuration file). A port can only listen on one MySQL service, so the same port number can only start one MySQL service at the same time. IV. Modify configuration file
You can fill in the server configuration you need in the configuration file. (# in the configuration file represents a single-line comment)
Here are a few basics, but you can also leave the configuration file empty and let the server use the default configuration. You can fill in the configuration you need by referring to the official documentation.
[mysqld] # specify the installation directory of mysql basedir=D:\ BaiduYunDownload\ mysql-8.0.12-winx64# specify the directory where the data of the mysql database is stored datadatadir=D:\ BaiduYunDownload\ mysql-8.0.12-winx64\ data# specify the port number port=3306# set the maximum number of connections allowed max_connections=200
Among them, the most important thing for the installation of multiple MySQL services is to specify the port number. Specify the configuration file during installation. If not, it defaults to the my.ini file in the installation directory (in the same folder as the bin directory). For MySQL services whose port number is not 3306, you need to add-P to log in to specify its port number.
After reading this article, I believe you have a certain understanding of how to install mysql with commands in cmd. You want to know more about it. Welcome to follow the industry information channel. Thank you for your reading!
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.