MySQL installation FAQ (File not found, system service cannot start...), mysql FAQ

Source: Internet
Author: User

MySQL installation FAQ (File not found, system service cannot start...), mysql FAQ

When installing mysql, you will always encounter problems. Every time you reinstall mysql, it will take a lot of time to troubleshoot. There are actually a lot of related articles on the Internet, but many of them only talk about the method, but do not talk about the specific details, leading to the failure to solve the problem. In fact, sometimes you know the cause of the problem, but it is always because you have not noticed some details. Repeated attempts waste a lot of time. Now, let's record the problems I encountered during the installation process and the issues that I should pay attention.

Environment: Windows 7

Mysql version: mysql-5.6.10-win32

If it is installed by default, mysql will be installed in the directory C: \ Program Files \ MySQL Server 5.6. Pay special attention to this directory. The following describes the causes.

In general, after installing mysql, we all want to connect directly, but the actual situation may not be smooth. After the installation is complete, enter the following command in CMD:

 

[Plain] view plain copy: view the CODE piece on the CODE and derive it to my CODE piece 01.C: \ Windows \ system32> mysql-uroot 02. 'mysql' is not an internal or external command, nor a program or batch processing file that can be run.

 

 

This is caused by the absence of environment variables. Of course, you can switch to the mysql installation directory before executing the command, but isn't that troublesome.

First, configure the environment variable and add the bin directory of the mysql directory to the path environment variable (the specific operation on how to set the environment variable is omitted can be implemented by google ).

 

After environment variables are configured, can I connect to mysql? Try mysql-uroot and slave. What is going on:

 

[Plain] view plain copy: view the CODE piece on the CODE and derive it to my CODE piece 01.C: \ Windows \ system32> mysql-uroot 02. ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

 

 

Why? Is the service not started? Let's start the service:

 

 

[Plain] view plain copy: view the CODE piece on the CODE to derive to my CODE piece 01.C: \ Windows \ system32> net start mysql 02. The service name is invalid. 03. 04. Type net helpmsg 2185 for more help.

 

 

Why is the service name invalid? Open the windows service and check that the mysql service is not installed after mysql is installed. We need to install it manually.

The mysql installation service is "simple". Enter the following in the command line:

 

[Html] view plain copy: view the CODE piece on the CODE and derive it to my CODE piece 01.C: \ Users \ MikanMu> mysqld -- install 02. Install/Remove of the Service Denied!

 

 

Why? This is because you do not have the permission. You must run the command as an administrator when starting the command. Close the current cmd window and run it as an administrator again:

 

 

[Plain] view plain copy: view the CODE piece on the CODE and derive it to my CODE piece 01.C: \ Windows \ system32> mysqld -- install 02. Service successfully installed.

 

 

Prompt that the installation is successful. Good. After installing the service, start up and look at it:

 

 

[Plain] view plain copy: view the CODE piece on the CODE to derive to my CODE piece 01.C: \ Windows \ system32> net start mysql 02. A system error 2 occurs. 03. 04. The system cannot find the specified file.

 

 

I went there. Why? You need to add the path to the mysql configuration file for various checks on the Internet:

Basedir = C:/Program Files/MySQL Server 5.6 datadir = C:/Program Files/MySQL Server 5.6/data

 

 

Okay, I'll try, the default configuration file for the mysql-5.6.10-win32 is in C:/Program Files/MySQL Server 5.6/my-default.ini, or create a my. ini file yourself and add configuration in it:

[Mysqld] basedir = C:/Program Files/MySQL Server 5.6 datadir = C:/Program Files/MySQL Server 5.6/data

 

 

Note: 1. Files cannot be directly created in the installation directory due to permission reasons. You need to create and add the corresponding configuration elsewhere, and then copy it to the installation directory C: /Program Files/MySQL Server 5.6.

2. Some online users say that the directory Separator in the configuration must be a forward slash '/', but after the experiment, '/', '\', and '\' are all correct, yes.

3. The basedir configuration is the installation directory of mysql. Remember, it must be configured to the directory C:/Program Files/MySQL Server 5.6, and cannot go to C: /Program Files/MySQL is complete.

4, my. ini file encoding must be English code (such as ANSI in windows), cannot be a UTF-8 or GBK.

After the above operations are completed (pay attention to the details), start the service again:

 

 

[Plain] view plain copy: view the CODE piece on the CODE to derive to my CODE piece 01.C: \ Windows \ system32> net start mysql 02. A system error 2 occurs. 03. 04. 05. The specified file cannot be found.

 

 

Why is this error reported? Isn't it because of configuration? Yes, it is not because of the above configuration problems, but there is no error after the above configuration is added. Why?

This is the most important thing to note. When installing the mysql service, you must switch to the bin directory of the mysql installation directory, whether or not you have configured the environment variables, otherwise, the preceding error is reported when the service is started after installation.

Switch to the bin directory, first Delete the mysql service installed earlier (the delete Service does not have to go to the bin directory), then re-install the mysql service in the bin directory, and then start: Be sure to run cd: enter the bin directory, even if you have configured Environment Variables

 

 

[Plain] view plain copy: view the CODE piece on the CODE and derive it to my CODE piece 01.C: \ Windows \ system32> cd .. /.. 02. 03.c:\> cd Program Files \ MySQL Server 5.6 \ bin 04. 05.C: \ Program Files \ MySQL Server 5.6 \ bin> mysqld -- remove 06. service successfully removed. 07. 08.C: \ Program Files \ MySQL Server 5.6 \ bin> mysqld -- install 09. service successfully installed. 10. 11.C: \ Program Files \ MySQL Server 5.6 \ bin> net start mysql 12. The MySQL service is being started. 13. The MySQL service has been started successfully.

 

Wow, it succeeded !!

Now let's verify that the my. ini file does not need to be added and the service can be started normally, as long as the service is installed in the bin directory. You only need to stop the mysql service, delete the service, and then put my. delete the INI file, reinstall the service, and start the mysql service to check whether the service can be started properly. The experiment proves that the service can be started normally.

 

 

[Plain] view plain copy: view the CODE piece on the CODE and derive it to my CODE piece 01.C: \ Program Files \ MySQL Server 5.6 \ bin> net stop mysql 02. the MySQL service is stopping. 03. the MySQL service has been stopped successfully. 04. 05.C: \ Program Files \ MySQL Server 5.6 \ bin> mysqld -- remove 06. service successfully removed. 07. 08.C: \ Program Files \ MySQL Server 5.6 \ bin> mysqld -- install 09. service successfully installed. 10. 11.C: \ Program Files \ MySQL Server 5.6 \ bin> net start mysql 12. mySQL service is starting. 13. the MySQL service has been started successfully.

 

 

The final success !!! Check whether the connection is successful:

 

 

[Plain] view plain copy: view the CODE piece on the CODE and derive it to my CODE piece 01.C: \ Program Files \ MySQL Server 5.6 \ bin> mysql-uroot 02. welcome to the MySQL monitor. commands end with; or \ g. 03. your MySQL connection id is 3 04. server version: 5.6.10 MySQL Community Server (GPL) 05. 06. copyright (c) 2000,201 3, Oracle and/or its affiliates. all rights reserved. 07. 08. oracle is a registered trademark of Oracle Corporation and/or its 09. affiliates. other names may be trademarks of their respective 10. owners. 11. 12. type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. 13. 14. mysql>

 

 

No problem at all.

 

In addition, the default root user of mysql does not set a password. You can modify the root user password as follows:

1. directly go to the cmd command line without entering mysql

 

[Plain] view plain copy view the CODE piece on the CODE to derive to my CODE piece 01. mysqladmin-u root password 'new password'

 

 

2. in mysql, you must connect to a database.

 

[Plain] view plain copy view the CODE piece on the CODE to derive to my CODE piece 01. mysql> use mysql 02. database changed 03. mysql> update user set password = password ('new password') where user = 'root'; 04. query OK, 3 rows affected (0.00 sec) 05. rows matched: 3 Changed: 3 Warnings: 0 06. 07. mysql> flush privileges; 08. query OK, 0 rows affected (0.00 sec)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.