简体   繁体   English

如何连接到SQLYog本地主机

[英]How to connect to SQLYog localhost or otherwise

I am new to working with servers, and am not able to use SQLYog because it is not able to connect to any server. 我刚接触服务器,但是无法使用SQLYog,因为它无法连接到任何服务器。 When I try to use the default values to connect to MySQL (localhost, root, port 3306), I get "Error No. 2003: Can't connect to MySQL server on 'localhost' (0). 当我尝试使用默认值连接到MySQL(本地主机,根目录,端口3306)时,出现“错误号2003:无法连接到本地主机(0)上的MySQL服务器”。

Is there something I am missing or that I have to correct? 我有什么想念的还是必须纠正的? I am just trying to create a database. 我只是想创建一个数据库。

SQLyog is just one way to connect to a MySQL database and interact with it. SQLyog只是连接到MySQL数据库并与其进行交互的一种方法。 Other popular methods include MySQL Workbench , Navicat , phpMyAdmin , and others. 其他流行的方法包括MySQL WorkbenchNavicatphpMyAdmin等。

Before you can use any of these, you have to first make sure your MySQL server is running and accepting connections. 在使用其中任何一种之前,您必须首先确保MySQL服务器正在运行并接受连接。 You didn't mention (or tag) whether you are running MySQL on your local machine, or what operating system you are using. 您没有提到(或标记)您是在本地计算机上运行MySQL还是使用什么操作系统。

A couple of the most common development environments are LAMP or WAMP, for "Linux, Apache, MySQL, php" or "Windows, Apache, MySQL, php" respectively. LAMP或WAMP是两个最常见的开发环境,分别用于“ Linux,Apache,MySQL,php”或“ Windows,Apache,MySQL,php”。 Since you tagged your question php , I'll assume one of these is appropriate. 由于您标记了问题php ,因此我认为其中之一是合适的。 (For example you're using SQLyog on Windows but your MySQL server is on Linux.) (I'll presume Ubuntu for Linux examples.) (例如,您在Windows上使用SQLyog,但您的MySQL服务器在Linux上。) (我将在Linux示例中使用Ubuntu)。

On the machine you've installed MySQL (along with any other components), you should be able to determine its running state by looking at your process list ( ps aux in Ubuntu, tasklist or Task Manager (GUI) in Windows). 在机器你已经安装了MySQL(和任何其他组件),你应该能够在你的进程列表中寻找确定其运行状态( ps aux在Ubuntu, tasklist或任务管理器(GUI)在Windows中)。

You're looking for mysqld (Linux) or mysqld.exe (Windows). 您正在寻找mysqld (Linux)或mysqld.exe (Windows)。 If the process isn't running, you need to start it ( Linux / Windows ). 如果该进程未运行,则需要启动它( Linux / Windows )。 If you're using WampServer (a popular Windows all-in-one package), for example, you can also look in your Windows Services for "wampmysqld" or "wampmysqld64" and start the service there. 例如,如果您使用的是WampServer (流行的Windows多合一软件包),则还可以在Windows服务中查找“ wampmysqld”或“ wampmysqld64”,然后在其中启动该服务。

If you can't get the process to start, you may have a configuration error. 如果您无法启动该过程,则可能是配置错误。 If the process is running, you may need to check the configuration any way to determine what port it is running on, if it's not the standard 3306. 如果进程正在运行,则可能不是标准的3306,您可能需要通过任何方式检查配置以确定其在哪个端口上运行。

The configuration file name and location can vary by system and package, but generally it will be called "my.cnf" (Linux) or "my.ini" (Windows). 配置文件的名称和位置可能因系统和程序包而异,但是通常将其称为“ my.cnf”(Linux)或“ my.ini”(Windows)。 Check your documentation for help on the specific path. 查看您的文档以获取有关特定路径的帮助。

Once you've got the service running, you should be able to connect! 服务运行后,就可以连接了!

SQLyog连接对话框

This is the default SQLyog connection dialog (at least in my slightly older version). 这是默认的SQLyog连接对话框(至少在我的旧版本中)。 The defaults assume you are running your MySQL server on your local machine (localhost), that you have a user "root" with no password, and the default port 3306 is used. 默认值假设您正在本地计算机(localhost)上运行MySQL服务器,并且拥有没有密码的用户“ root”,并且使用了默认端口3306。

You'll need to change any of this information that differs on your particular installation. 您需要更改任何与您的特定安装不同的信息。

Be aware that if you're trying to connect to an instance of MySQL on another machine, a firewall may be blocking a port. 请注意,如果您尝试连接到另一台计算机上的MySQL实例,则防火墙可能会阻止端口。

These steps should hopefully get you on the right track. 这些步骤有望使您走上正确的道路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM