如何在Windows XP上启动MySQL服务器
每当我尝试通过键入启动 MySQL 时,
> mysql -u root
都会收到错误
错误 2003(HY000):无法连接到“localhost”上的 MySQL 服务器 (10061)
如何解决上述问题?我刚刚下载了MySQL并将其解压在E:盘中。我没有做任何其他事情。我必须先建立连接吗?如果是这样,我该怎么做?
Whenever I try to start MySQL by typing
> mysql -u root
I get the error
ERROR 2003(HY000): Can't connect to MySQL server on 'localhost' (10061)
How can I solve the problem above? I just downloaded MySQL and unzipped it in the E: drive. I have not done anything else. Do I have to make a connection first? If so, how can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(19)
这是我下载的 ZIP 文件: mysql-5.7.15-winx64.zip
以下是在 Windows 上首次启动 MYSQL Server (mysql-5.7.15-winx64) 的步骤:
mysqld --initialize-insecure
或mysqld --初始化
取决于您是否希望服务器为'root'@'localhost'帐户生成随机初始密码。mysqld --console
即可看到启动正在打印日志。mysql -u root -p
。出现提示时,如果已设置密码,请输入密码,否则只需按“Enter”按钮即可连接Here is the ZIP file that I had downloaded: mysql-5.7.15-winx64.zip
Here are the steps to start MYSQL Server (mysql-5.7.15-winx64) for the first time on Windows:
mysqld --initialize-insecure
ormysqld --initialize
depending on whether you want the server to generate a random initial password for the 'root'@'localhost' account.mysqld --console
You can see the start-up logs being printed.mysql -u root -p
. When prompted, Enter password if it has been set or else just hit "Enter" button to connectMySQL 服务器可以从命令行手动启动。这可以在任何版本的 Windows 上完成。
要从命令行启动 mysqld 服务器,您应该启动控制台窗口(或“DOS 窗口”)并输入以下命令:
您可以通过执行以下命令停止 MySQL 服务器:
**注意:**
如果 MySQL root 用户帐户有密码,您需要使用 -p 选项调用 mysqladmin 并在出现提示时提供密码。
该命令调用 MySQL 管理实用程序 mysqladmin 连接到服务器并告诉其关闭。该命令以 MySQL root 用户身份进行连接,这是 MySQL 授权系统中的默认管理帐户。请注意,MySQL 授权系统中的用户完全独立于 Windows 下的任何登录用户。
如果 mysqld 没有启动,请检查错误日志以查看服务器是否在其中写入任何消息来指示问题的原因。错误日志位于C:\Program Files\MySQL\MySQL Server 5.0\data目录中。是后缀为.err的文件。您还可以尝试使用 mysqld --console; 启动服务器;在这种情况下,您可能会在屏幕上获得一些有用的信息,这可能有助于解决问题。
最后一个选项是使用 --standalone 和 --debug 选项启动 mysqld。在这种情况下,mysqld 会写入一个日志文件 C:\mysqld.trace,其中应包含 mysqld 未启动的原因。请参阅 MySQL 内部结构:移植到其他系统。
通过 MySQL 官方页面
The MySQL server can be started manually from the command line. This can be done on any version of Windows.
To start the mysqld server from the command line, you should start a console window (or “DOS window”) and enter this command:
You can stop the MySQL server by executing this command:
**Note : **
If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.
This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system. Note that users in the MySQL grant system are wholly independent from any login users under Windows.
If mysqld doesn't start, check the error log to see whether the server wrote any messages there to indicate the cause of the problem. The error log is located in the C:\Program Files\MySQL\MySQL Server 5.0\data directory. It is the file with a suffix of .err. You can also try to start the server as mysqld --console; in this case, you may get some useful information on the screen that may help solve the problem.
The last option is to start mysqld with the --standalone and --debug options. In this case, mysqld writes a log file C:\mysqld.trace that should contain the reason why mysqld doesn't start. See MySQL Internals: Porting to Other Systems.
Via MySQL Official Page
如果命令提示符在 Windows 中不起作用,请尝试以下操作:
1) 在 Windows 中打开服务。
2)然后检查Mysql的状态,如果发现状态为空或空白,则启动mysql服务。
3)然后查看mysql是否启动。如果显示已启动,则尝试检查mysql是否正常工作。
当 cmd 命令不起作用时,它对我有用。
If the command prompt does not work in Windows, try the following:
1) Open services in Windows.
2) Then check the status for Mysql and if you found status nothing or blank then start the mysql service.
3) After then see whether the mysql is start or not .If it shows started then try to check mysql working.
It has worked for me when cmd commands were not working.
以管理员身份运行命令提示符并cd到MySQL的bin目录
运行命令:mysqld --install。 (此命令将安装MySQL服务,如果服务已安装,则会提示。)
运行以下命令来启动和停止服务器
启动:net start mysql
停止:net stop mysql
运行mysql命令。 p>
享受吧!!
Run the command prompt as admin and cd to bin directory of MySQL
Run command : mysqld --install. (This command will install MySQL services and if services already installed it will prompt.)
Run below commands to start and stop server
To start : net start mysql
To stop : net stop mysql
Run mysql command.
Enjoy !!
或许
maybe
键入
启动 sql server,然后测试客户端连接。
Type
to start the sql server and then test the client connection.
我使用的是 MySQL Server 5.5,因此我丢失了大多数答案在
bin
文件夹中提到的文件夹。我所做的如下:MySQLInstanceConfig
并按照下图操作。这解决了我的问题,我能够毫无错误地访问数据库。
I was using MySQL Server 5.5 as a result I was missing the folder which majority of the answers made mention of in the
bin
folder. What I did instead was the following:C:\Program Files\MySQL\MySQL Server 5.5\bin
or your MySQL installation directory.MySQLInstanceConfig
and follow the images below.This solved my issue and I was able to access the database without any errors.
启动mysql服务器
通过命令提示符C:> "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --console
或者替代方案到达 bin 然后
mysqld --console
它将启动您的服务器。
如果您有可用的 mysql 命令行客户端,
请单击它
,它会显示输入您的密码:
请输入您的密码。
然后您就可以访问它。
Start mysql server by command prompt
C:> "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --console
Or alternative reach up to bin then
mysqld --console
It will start your server.
If you have mysql command line client available
click on it
it show enter your password :
Please enter your password.
Then you can access it.
您还需要配置并启动 MySQL 服务器。 这可能会有所帮助
You also need to configure and start the MySQL server. This will probably help
我尝试按照以下步骤在 Windows 8 上运行 mysql server 5.6。
I tried following steps to run mysql server 5.6 on my windows 8.
您需要先运行服务器。您使用的命令(在问题中)启动客户端连接到服务器,但服务器不存在,因此出现错误。
由于我不是 Windows 用户(配备了 Linux),所以我可能不是告诉您如何操作的最佳人选,但我可以向您指出 指南 和另一个 指南,向您展示如何在 Windows 中启动并运行 MySQL 服务器。
运行后,您可以使用命令(在问题中)来连接它。
注意:您也可以尝试 http://www.apachefriends.org/en/xampp.html< /a> 如果您计划使用 MySQL 进行 Web 数据库开发。
希望这有帮助。
You need to run the server first. The command you use (in the question) starts a client to connect to the server but the server is not there so there the error.
Since I am not a Windows user (Linux comes equipped) so I might not be the best person to tell you how but I can point to you to a guide and another guide that show you how to get MySQL server up and running in Windows.
After you get that running, you can use the command (in the question) to connect it.
NOTE: You may also try http://www.apachefriends.org/en/xampp.html if you plan to use MySQL for web database development.
Hope this helps.
该错误抱怨的是
localhost
而不是权限,并且 MySQL 中当前的做法是使用指定localhost
的绑定地址 > 仅在配置文件中。所以我不认为这是一个密码问题——除了你说你“解压”了MySQL。
安装够了吗?你下载了什么?
是否有任何安装步骤允许您定义 root 密码?
而且,正如 NawaMan 所说,服务器正在运行吗?
The error complains about
localhost
rather than permissions and the current practice in MySQL is to have a bind-address specifyinglocalhost
only in a configuration file.So I don't think it's a password problem - except that you say you 'unzipped' MySQL.
Is that enough installation? What did you download?
Was there any installation step which allowed you to define a root password?
And, as NawaMan said, is the server running?
你需要做的第一件事是启动 mysql
为此你可以使用
E:\mysql-5.1.39-win32\bin>net start mysql
(仅当有 mysql 作为服务运行时)然后你可以执行
E:\mysql-5.1.39-win32\bin>mysql -u root
first thing you need to do is to start the mysql
for that you can use
E:\mysql-5.1.39-win32\bin>net start mysql
(only when there a mysql running as service)then you can execute
E:\mysql-5.1.39-win32\bin>mysql -u root
我们可以使用以下命令从 Windows 命令行启动 MySQL 服务。
net start mysql
停止MySql服务的命令:
net stop mysql
禁用MySql服务:
sc config mysql start=disabled
开启MySql服务的命令(系统启动时自动启动MySQL服务):
sc config mysql start= auto
设置启动类型为手动的命令:
sc config mysql start=manual
如何重启MySql服务?
没有直接命令来重新启动服务。您可以组合停止和启动命令,如下所示。
net stop mysql &网络启动mysql
We can start MySQL service from windows command line using the below command.
net start mysql
Command to stop MySql service:
net stop mysql
Disable MySql service:
sc config mysql start= disabled
Command to enable MySql service(to automatically start MySQL service when the system starts up):
sc config mysql start= auto
Command to set the startup type to manual:
sc config mysql start= manual
How to restart MySql service?
There is no direct command to restart a service. You can combine stop and start commands like below.
net stop mysql & net start mysql
我在启动 MySql 服务器时也遇到问题,但按照图片中右侧标记运行命令。它工作正常。
I was also having problem with starting MySql server but run command as mention right mark in picture . Its working fine .
在终端中输入此命令后,它会要求输入密码
输入密码即可开始!
After entering this command in terminal, it will ask for password
Enter the password and you are ready to go!
有一个最好的解决方案可以解决这个问题,并且 100% 有效。
我们知道服务器是一个进程,因此请将其视为进程,转到任务管理器
在Windows中并在任务管理器中查看服务,在该服务中查看
Mysql
和MS80
并尝试启动它手动单击它并说运行然后将需要一些时间。there is one of the best solution do resolve this problem and it is going to work 100%.
as we know that server is a process so treat it like a process go to the task manager
in windows and see for services in task manager in that service see for
Mysql
andMS80
and try to start it manually by click on it and say run then will take some time.1.以管理员身份打开命令提示符。
2.进入程序文件中MySQL安装的bin目录。
3.从Windows资源管理器复制bin目录的位置。
4.在命令提示符下键入 cd 并(粘贴位置)并输入。
5.键入 mysqld --initialize
6.从 Windows 菜单中打开服务并按名称对列表进行排序。
7.右键单击Mysql,然后单击启动。
1.Open a command prompt as Administrator.
2.Go to MySQL installed bin directory in program files.
3.Copy the location of the bin directory from windows explorer.
4.In command prompt type cd and (paste the location) and do enter.
5.Type mysqld --initialize
6.Open services from the windows menu and sort the list by name.
7.Right-click Mysql and click start.
在 bin 文件夹路径中使用命令“mysql -u root -p”。
并提供您之前设置的 MY SQL 密码。
use the command "mysql -u root -p" in the bin folder path.
and give the MY SQL password which you have set earlier.