Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the problems with mysql reinstallation

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the mysql reinstallation questions, the text is very detailed, has a certain reference value, interested friends must read!

Recently encountered a problem to reinstall the system, but fortunately mysql installation directory is not installed in the system disk.

So how do I retrieve the data from MySQL?

To cut a long story short, let's start with the context. Knowledge has increased.

Have you ever installed mysql under Linux and forgotten your mysql root password? (Or Windows) Have you ever configured jdk environment variables?

Haha ~ I believe that many friends and I have had the same experience.

Is it crazy to find the password and not log in? Install a mysql have experienced a variety of tribulations, even small partners because of database problems ~ _~ ! A failed installation leads to unsuccessful reinstallation. He even reinstalled the system later.

Here are the answers to all your questions:

Take mysql8.0 + Windows environment as an example:

If you do not select a path when installing mysql, then mysql is installed on drive C by default. If you have a specified installation path, mysql will be installed on drive C by default.

Find out where MySQL is installed.

If you have previously installed Mysql

Then first check whether there is mysql service in the service. This computer ==> Management ==> Service and Application ==> Service is shown as follows

Uninstall mysql services, if there are redundant services can be passed through

sc.exe delete service name Delete useless services. Restart your computer after deletion.

sc.exe delete MySql

You can also use mysqld.exe remove to find the location of the service by viewing the service properties (this may not work, if the path goes wrong)

If the original file is still there, you can remove the service through mysqld.exe under this path

Let's do an experiment, experience how to configure the decompressed version (green) mysql, need to be executed under a Windows that has not installed mysql, you can use VMware virtual to install a Windows environment, about Windows download can be found in my installation operating system, https://msdn.itellyou.cn/has all Windows system ed2k link mirror, download it

The first step, go to mysql official website to download a free installation version of MySQL zip package

https://dev.mysql.com/downloads/mysql/

Then unzip it and go into the unzipped directory to see if there are the above files

Step 2: Install services and initialize mysql

Run the powerShell window as administrator via Windows logo + X and then via A

Note that you must run as an administrator, otherwise an error will be reported later (CMD also works as an administrator)

Switch to the unzipped directory:

the corresponding command

Start with:/

Then cd to unzipped directory

You can also press Shift + right mouse button to open a powershell window.

as shown below

Start installing the service officially. This mysqld is actually the mysql service program, so running mysqld is running the mysql service.\ mysqld.exe install

If prompted mysql has been installed then find the mysql service in the service, start the mysql service, or remove the service by mysql.exe stop stop first

initialization

.\ mysqld.exe --initialize-insecure --user=mysql

As shown in the above figure, you will get the data folder, which stores the database information. After deletion, the database is not there. You need to re-operate before you can

You can't log in yet. You need to start the service manually.

The first time you use mysql, you can log in directly through mysql.exe -u root -p. If there is no content in the database, delete the data folder (manually close the mysql service to delete it)

Then manually restart the service, reinitialize the database How to log in (first time do not need a password) Change the following 123456 to the password you want

Modify root password (need to operate in bin directory of mysql, if environment variables are configured, you do not need to operate in bin directory).\ mysqld.exe -u root -puse mysql;ALTER USER `root`@`localhost` IDENTIFIED BY '123456'; If you just want to install mysql, then the above installation is finished. The following is the root password forgotten. Go to Step 1 of the database modification operation. Shut down the service. You can also manually shut down the service (previous screenshot) by entering the following command net stop mysql Step 2.(Administrator identity)cd to the bin directory of mysql home directory.\ mysqld.exe --console --skip-grant-tables --shared-memory

Fig.

You need to open another powershell window. Hold down the Shift right mouse button under the bin directory and there will be a powershell window open here.

Then log in (do not need to enter password) directly enter to log in

.\ mysql.exe -u root -p

Enable mysql database

use mysql;

The authentication_string here is not a password. The operation behind it is the real password modification.

update user set authentication_string='' where user='root';

The above is just to run root password-less login, because the previous sql that caused the password to be modified via the--skip-grant-tables option: ALTER USER `root`@`localhost` IDENTIFIED BY '123456'; password cannot be modified

log out

quit

And close that execution command window with--skip-grant-tables.

Then start the mysql service

net start mysql

According to normal login, you can log in without entering the root password.

.\ mysql.exe -u root -puse mysql;

Change root password

ALTER USER `root`@`localhost` IDENTIFIED BY '123456'; Have questions during use of mysql? Where exactly is mysql's data source located? Answer below

The mysql data source is actually in the data folder. Let's try an experiment.

Purpose of use:

Prove that the mysql data source is in the data folder, and you can find the original data directly using mysql by specifying the data source path. Even if mysql is not installed on your computer, you can continue to use the original mysql database and data by copying the original mysql installation directory;

Experimental part:

In order for the experiment to have an effect, we create a database, which is simply called demo (if you have a database yourself, it is better to directly experiment below).

The following use even if you have not installed mysql database, you can also operate, just mysql home directory can be (data folder)

Step 1: Close mysql service net stop mysql Step 2: Create my.ini text file to specify mysql location and data source location

Copy the data folder under the mysql home directory to the D:/packing directory. You need to close the service before you can move it. Otherwise, you will be prompted to use the background!

Create a new my.ini text file (simply put it in D:\mysql-8.0.18-winx64, that is, put it in the main directory, and there is no such file before 5.5)

Write the following code specifying the home directory, data source path, and port of the database

[mysqld]basedir = D:\mysql-8.0.18-winx64datadir = D:\dataport =3306 Then start mysql service through mysqld as shown below

In fact, you can also link mysql through third-party tools such as Navicat.

The following command connection, you need to open another window

You can see here that MySQL is connected and is the original database!!

Counterexample Test 1

Close the front so powershell window

Remove my.ini from the previous one, so mysqld can't find the data source, see what error it indicates

Here execution fails because there is no my.ini to tell mysqld where the mysql home directory is and where the data source is

Now through.\ mysql.exe -u root -p must not connect because mysql services are not started

Counterexample Test II

Remove datadir from my.ini, as shown below

And then try the same thing.

At this point reported a bunch of errors, the specific error to see the error tips, and then you only need to modify according to the error tips can be,

For example, the first ERROR prompt cannot find the error message file

error-message file Just specify the correct location in the configuration file

The above is "mysql reinstall what questions" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report