Can't start MySQL, port 3306 busy - mysql

I'm trying to start MySQL from XAMPP (under Windows Vista), but it's saying that's port 3306 is busy.
What would be the best way with check what application is using that port and how to free it?

Just Open task manager and Kill MySql service.

In a command shell, run:
netstat -b -p TCP
or
netstat -an | grep -i listen | grep -E 3306
The first command will output a list that you will need to look through for the line that displays localhost:3306 in the second column. Below this is the application's name using the port.
The secondary command will find find the exact port you are looking for and looks something like this:
<example-name>:user <example-name>$ netstat -an | grep -i listen | grep -E 3306
tcp46 0 0 *.3306 *.* LISTEN

I had the same problem and was stuck on this thing for a day and I couldn't find a perfect answer anywhere.
So I gave it a shot on my own and it worked. This solution is for Windows users. I use Windows 7.
My xampp control panel was displaying an error that port 3306 is busy and in use by some file (name was specified).. say "filename.de".
Now follow the following steps:
press Ctrl+Alt+Del and open Task Manager.
Open the "Processes" list and Check for "show all processes" under the list of processes. If you don't see any such option, don't worry! as sometimes administrator permission is required to show some processes.
Now, when you click on "show all processes" button, all the process will be displayed.
Now, switch to "services" tab in the task manager, and a list of services will be displayed. Now look for a service named "filename.de" <-- filename that was diplayed in the error message in xampp.
When you find that service, 'right-click', and then click in option.. GoTo Process.
You will be redirected to the "Processes" tab with focus on a process corresponding to that service. 'Right-Click' and then click on "end process tree".
Now, the issue has been solved! But might have to do the same thing again when you restart your PC. So it is best to keep your PC in sleep-mode.
Otherwise, to solve this issue permanently, open "msconfig" and uncheck that particular process from the services list and click on apply. and you can restart your system.

I've been having trouble for hours on this error. I was trying to run MySQL from XAMPP after quite some time. It gave errors, similar to yours, it said that port 3306 is in use. If you:
are running on Windows 10
are avoiding to change the port number of MySQL from 3306
can't see any program using the 3306 port from netstat
reinstalling and deleting everything yet it still give the same error
are enabling and using Hyper-V
all of the other solutions didn't work
This is the solution that worked for me:
Go to the most right of the taskbar and right-click the connection icon, click Open Network & Internet settings
Click Change adapter options
Right-click and Disable everything that relates to Hyper-V
I ran MySQL again at now it works.

As Mentioned By #Segun Emmanuel Run the Following Command:
netstat -a -b
You will get a list of Applications that are using different PORTS. Press Ctrl + F and write 3306 to find out which Application is using PORT 3306.
After this, Go to Task Manager via Search Bar or by pressing CTRL + ALT + DEL. Then Under the Background Processes, find out mysqld.exe, right-click on it and you will find an option to close it, namely "End Task".
Then go to your Xampp Control Panel and start the MySQL service.

If mysql is not starting in xampp, it might be a port conflict issue. Mysql run by default on port 3306. you need to check if another application is occupying that port. use following command to check app occupying a port
Linux: netstat -tulpn | grep 3306
Window: netstat -a -b
Mac: lsof -nP -i4TCP:3306
if you find an application occupying that port, stop the application and restart xampp. As an alternative, you can go to php.ini file or click configure in the xampp for mysql and change the mysql port to 3307

In my case it was javaw.exe which was starting on port 3306. This exe does not cause problem if I am logged in using single user in my Windows 10. But if I have multiple logins, it starts this exe for each user and blocks MySQL to start on 3306 port.
Going to task manager and killing this exe for the other user fixed the issue and MySQl could start.

Windows icon -> Open cmd.exe.
Type netstat -a -b.
Find what's using it. In my case it was this:
So, I went to task manager. There were no process called so. The I went to services and disabled these two:
Now everything works fine.

I had this problem (slight variation as I was using MAMP)
I found this problem was due to having MySQL Workbench installed, MySQL Workbench started the mySQL service on bootup which in turn stopped MAMP being able to use the port.
To fix this I had 2 options,
Uninstall MySQL Workbench
Open Task, click services tab, kill the current MySQL service
This then allowed MAMP to use port 3306

This error occurs if you have installed mysql two times. mysql by default uses the port 3306. If you have installed it twice then already there is a mysql at your port number 3306. So you will have to change your port.
If you are using xampp then you can easily change your port. Steps to change port:
Step 1: Open your xampp as administrator.
Step 2: Click on 'Config' at the top right corner of your xampp.
Step 3: Click on 'Service and Port Settings' and after that change the main port of mysql from 3306 to 3307 and the click on save.
Step 4: Then click on 'config' which is in front of mysql and open 'my.ini' file which will be a text file.
Step 5: Now wherever in the text file you see the port number mentioned as 3306 change it to 3307 and then save the file.
After doing this again start your mysql server and it will start running on port 3307.
This worked for me and I hope it will work for anyone else who encounters the same issue.

This command kills the existing mysql process and perhaps one can start it afresh
sudo pkill mysql
It has helped me solve this challenge most of times
1. Turn off the application which is using this port, open terminal and run "lsof -n -P -i | grep 3306" to figure out.
2. Use different ports, right click on the server -> Edit.

For this problem, a simpler way on Windows is:-
Go to Task Manager
Go to Services
There will be a services named MySQl80 right click on it and then select
"Stop"
Try and start the MySQl module on XAMPP server again

If you where not able to find any application or process listening on port 3306, you might need to check your network adapters.
Disable adapters you do not use.
Pay also attention to the Hyper-V generated network adapter, disable it if you don't need it. Sometimes it can reserve some ports and commands like netstat will not be able to find it out

Run XAMPP with Administrator
If you already installed MySQL Service, Uninstall it and install again. If you not already install it install MySQL Service.

Related

Windows start mySQL server from command line

I have looked for an easy way to start a mysql from the command line.
I know about
"
shell> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld"
The path to mysqld may vary depending on the install location of MySQL on your system.
"
But I want something more like linux where you can type "sudo service mysql stop/start/status"
I have the mysql path setup so I can run mysql commands like "mysql -u root -p"
I am not sure if it is possible either.
I want to know if anyone has a way to do this.
Using the help from the comments I have solved my issue, for anyone else.
When I installed mysql it gave me the option to name the service for the server
Mine is called "MySQL57" (this meant mine was already a service. If your's isn't I would follow this: Mysql service is missing although I can't guarantee it worked)
If you aren't sure you can open services with: windows key + R then type in "services.msc"
You can start and stop windows services with "net start/stop service-name"
For CMD I need to run as admin then type "net start mysql57"

Cannot connect to MySQL Workbench on mac. Can't connect to MySQL server on '127.0.0.1' (61) Mac Macintosh

Cannot connect to MySQL Workbench on mac. I get the following error: Could not connect, server may not be running. Can't connect to MySQL server on '127.0.0.1' (61)
The help would be appreciated.
Thank You!
Ran into a similar issue and my problem was that MySQL installed itself configured to run on non-default port. I do not know the reason for that, but to find out which port MySQL is running on, run the following in MySql client:
SHOW GLOBAL VARIABLES LIKE 'PORT';
Go to System preferences -> MySql and check the state of your MySql instance.
There may be one or multiple reasons if you are not able to connect to MAC OS X MySQL server with MySQL-workbench.
When you press 'test connection' you might see this error. This could be explained briefly if you go step by step through 'Configure server management..'
On the basis of the red crosses you can filter out the real problem.
The most common problems are associated with the installation of MySQL-server. Few people either forget to install the server prior to installing MySQL-workbench. Some others would install a part of the product. Please check whether you have also installed all the 3 parts that comes with the MySQL-Server dmg(disk image) file which contains mysql-server package. Those 3 parts are: MySQL server, preference pane and startup item.
Note: If you haven't selected preference pane then you won't be able to start mysql server instance from the System preferences.
After you make sure that you have installed each item then you can check server instance of your native mysql-server. Open System preferences from dock and click MySQL. Then click Start MySQL Server to start the server instance. If the server instance is stopped, then MySQL-workbench won't be able to connect to the MySQL server.
If you are still facing issue, then you need to check the port of the connection which you are making. Default port is '3307' and NOT '3306'. You can check it with using the following command in mysql terminal:
SHOW GLOBAL VARIABLES LIKE 'PORT';
Please note that this process helps you to connect to the local instance. If you have to connect to a remote server, then you have to enter that specific IP and Port. Contact your server's administrator if you are facing the issue. As this question specifically states that the problem is related to connecting to the local instance, I am not writing checks that you may need to ensure.
This steps are all in the terminal:)->source
Step make sure your server is running:
sudo /usr/local/mysql/support-files/mysql.server start
Check MySQL version. "This also puts you in to a shell interactive dialogue with mySQL, type q to exit."
/usr/local/mysql/bin/mysql -v
Make your life easier: "After installation, in order to use mysql commands without typing the full path to the commands you need to add the mysql directory to your shell path, (optional step) this is done in your “.bash_profile” file in your home directory, if you don’t have that file just create it using vi or nano:"
cd ; nano .bash_profile
paste in and save:
export PATH="/usr/local/mysql/bin:$PATH"
"The first command brings you to your home directory and opens the .bash_profile file or creates a new one if it doesn’t exist, then add in the line above which adds the mysql binary path to commands that you can run. Exit the file with type “control + x” and when prompted save the change by typing “y”. Last thing to do here is to reload the shell for the above to work straight away."
source ~/.bash_profile
mysql -v
"You will get the version number again, just type “q” to exit."
Check out on which port the server is running:
in your terminal type in: mysql
and then
SHOW GLOBAL VARIABLES LIKE 'PORT';
use everytime a semikolon in the mysql client (shell)!
now you know your port and where you can configure your server(in the terminal with mysql shell/client). but for a successful connection with MySQL Benchmark or an other client you have to know more. username, passwort hostname and port. after the installation the root user has no passwort so set(howtoSetPW) the passwort in terminal with mysql shell/client. and the server is running local. so type in root, yourPW, localhost and 3007. have fun!
Try restarting the mysql or starting it if it wasn't started already. Type this within terminal.
mysql.server restart
To auto start go to the following link below:
How to auto-load MySQL on startup on OS X Yosemite / El Capitan
In my case I had a previous mySQL server installation (with non-standard port), and I re-installed to a different directory & port. Then I got the same issue (in windows). To resolve, you click on home + add new connection.
If you need to know the port of your server, you can find it when you start My SQL command line client and run command status (as below). In windows it is via All Programs -> MySQL -> MySQL ServerX.Y -> MySQL X.Y Command Line Client
I had the same issue, I solved this with the following steps:
Install the MySql (DMG) from this link
If the mysql package comes with the file name "mysql-5.7.13...." and
"MySql.prefPane" then your life is really easy.
Just click on "mysql-5.7.13...." and follow the instructions.
After the installation is done, click on "MySql.prefPane" and checkout "Only
for this user" in the popup. We use "MySql.prefPane" to start the mysql
server as this is really imp because without this you will end up having
errors.
Click on Start MySql Server in the next dialog box.
OR
If you don't see "MySql.prefPane" in the package then follow these steps:
Click on package "mysql-5.7.13...." and this will show you one password as
soon as installation is done. That password is use to start the connection.
You can change it. I will let you know in a while.
After installation save the password (this is really important - you'll need it later), open terminal.
$ cd /usr/local/mysql/bin/
$ ./mysql -u root -h localhost -p
And then type the password from above. This should start mysql>
To change the password:
$ cd /usr/local/mysql/bin/
$ ./mysqladmin -u root -p password 'new_password'
Enter Password: <type new password here>
$ ./mysql -u root -h localhost -p
... and log in with the new password.
After this you can go to MySql workbench and test connection. It should connect.
brew services start mysql defualt set --bind-address=127.0.0.1 with /usr/local/Cellar/mysql/5.6.27/homebrew.mxcl.mysql.plist,so replace --bind-address=127.0.0.1 with --bind-address=* or --bind-address=0.0.0.0
for mac : check the compatible version of mysql server in workbench>preference>MySql
if it's the same version with your mysql server in: cd /usr/local/
I am using those commands on MacOs after getting the same error
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart
I had the same problem. I removed mySQL completely, and reinstall it using homebrew.
I had same problem, but it worked for me.
check if you have mysql installed
If you don't have mysql installed, download from this link: https://dev.mysql.com/downloads/mysql/
follow this instructions to install
https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/osx-installation-pkg.html
You can test the connection without any problem.
(Sorry for my english, I agree fix me please)
I Hope I've helped.
Greetings.
I ran into the same scenario
I opened "System Preferences", clicked "MySQL", then clicked "Initialize Database" button. I entered a new password and saved it in a safe place.
After that i restarted the MySql Instance (in the System Preferences dialog as well).
After that i opened MySqlWorkbench and opened the default connection, entered the password i set before and: Viola, i can do whatever i want :-)
I had this same issue on Monterey. Make sure you're selecting the correct download according to your processor architecture.
Community download processor architecture
Also, for the Connection Method use the Local Socket/Pipe
connection method
Dropping this to share my experience.
I had the same problem and realise I didn't start MySql server.
The steps below shows how I was able to login:
To start your server, Go to Preference and find MySql.
Click on the instance tab to start the server
Afterward, return back to Mysql Workbench to start the Local Instance and you'll be connected.
Have fun !
I had similar issues in Mac OS Catalina and the easiest way to solve it is by downloading HOMEBREW package manager for mac. Follow the steps to install HOMEBREW and mysql server.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install mysql
$ brew tap homebrew/services
$ brew services start mysql
mysqladmin -u root password 'yourpassword'
Now try using mySQLworkbench it should work.

ERROR 2003 (HY000): Can't connect to MySQL server on localhost (10061)

I installed MySQL on Microsoft Windows 8 Using a noinstall Zip Archive. But when I tested by executing the following commands on windows prompt, the above error showed up.
C:\> "C:\MySQL\bin\mysqlshow"
C:\> "C:\MySQL\bin\mysql" test
You don't need to restart your windows. The easiest way to achieve this is
Go to <Extracted folder location>/bin/
Run mysqld (service)
close the cmd prompt
Run mysql.exe or the better way to do is add the location to PATH environment Variable
Go to Run type services.msc. Check whether MySQL services is running or not. If not, start it manually. Once it started, type mysqlshow to test the service.
Go to bin directory copy the path and set it as a environment variable.
Run the command prompt as admin and cd to bin directory.
Run command : mysqld –install
Now the services are successfully installed
Start the service in service windows of os
Type mysql and go
Though it is an old question, I am adding my answer in it, because the solution that worked for me on Windows 7 as an admin user, is missing in the answers' list. Though my solution is for installed MySQL, I am putting it for those who search for a solution for this error message. Here it is:
Click on the Windows 7 start button and type taskmgr in the search bar
Right click on the taskmgr program icon and select Run as administrator
In the Task Manager window, go to the Services tab
Right click on the MySQL service and click Start Service
The solution that worked for me is:
Downloaded mysql-8.0.22-winx64.zip file
Extracted the zip file
Moved the extracted folder to C:/Program Files
Opened cmd.exe as admin
Navigated to the directory cd C:\Program Files\mysql-8.0.22\mysql-8.0.22-winx64\bin
mysqld -install (Service successfully installed)
mysqld --initialize (no prompt)
Opened services.msc
Found MySQL
Right-click and start
I was stuck on this same issue for what felt like an eternity.
My problem was: I was running mysql from MAMP on port 8889, but when trying to connect to mysql from my command line, it was expecting port 3306. I was running out of ideas, so I tried:
mysql --port 8889
and happiness ensued:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.34-log MySQL Community Server (GPL)
Go to Run type services.msc. Check whether MySQL services is running or not. If not, start it manually.
Run your cmd as administrator.
What you will see is like this:
c:\windows\system32>
Go to your bin location by using cd..
like C:\mysql\bin (my location of bin in my computer is what you are seeing so chose yours correctly)
Run:
$ C:\mysql\bin>mysql --install
Service successfully installed.
Then run:
$ C:\mysql\bin>NET START MySql
The MySql service is starting
The MySql service was started successfully
Then the last step is running:
C:\mysql\bin>mysql -u root - p admin
It will ask for password don't enter anything first time
because it will use blank, and just press enter you are done.
And later you can set password too.
I have a windows 8.1 machine and mysql was not running at all even after trying to start mysqld with no error logs. This solution worked for me:
start cmd in admin mode
type in "net start mysql"
close current cmd window and open new cmd window
type in "mysql"
The mysqld service should now be available.
Had this issue in Windows 10 and MySQL 8. Resolved by following steps:
Searchbar(bottom left) > Task Manager > Run as administrator > Services > MySQL80
Well that could have some reasons.
THe first one is that the MySQL server/service not started.
If he is started you should check out the logfiles, and make sure there are no problems.
You could also uninstall the MySQL service and install XAMPP.
With XAMPP it is easier to manage this services.
Despite that my server was running, I had the same problem.
I found out that it was the port. So you need to specify the port:
mysql -u user -p --port 0000
The port on your machine may be different. To find out on which port mysql is running open the mysql ini file and look for port=. A port often used is 3306.
Example how to log on to mysql
mysql -u root -p --port 3306
Test if the server is running. You can use netstat for this. See https://serverfault.com/questions/260239/unable-to-connect-to-mysql-through-port-3306
If it is running, it may be the firewall. You can turn that off to test if that is the problem.
See the following manual to install Mysql as a service: https://dev.mysql.com/doc/refman/5.5/en/windows-start-service.html
First of all, you need to ensure the port number on which the server is running. Then you can run
mysql -u username -p --port portNumber
on the command line
Executing the mysqld command can solve your problem.
My SQL version is 5.7.
If you're using the no install zip, you need to execute mysqld.exe first to start the service, and then execute mysql.exe to open your connection.
The no install is nice, but if you intend to do any serious work with MySQL, you may want to consider either using the MSI to do a proper installation, or if you're doing web development work give XAMPP a try.
Check Mysqld.exe file is in your bin folder. if it is not there , just copy that file from any other computer and paste it on your bin folder.Just double click. Then run mysql.its solved
This error is flashed when we are trying to open mysql with out stating the service.
Open cmd prompt
to start the service type
mysqld --console
This will start the mysql service
Don't close this cmd prompt and open a new cmd prompt and
type
mysql -u root -p
Then enter ur password
Make sure your mysql is running in default port (3306) , if you are running mysql with different port (for example: 3307), you must specified the port number while connecting to the server.
If your port is different than default port, then try with this command.
mysql -u <username> -p --port<port number>
For eg:
mysql -u root -p --port 3307
Go and search Services in Windows
Now search Mysql. Right Click on it. By Default it's startup type will be 'Automatic'. Click on Properties on right clicked menu.
You will find startup type Switch it to -> Manual So that We can start and stop by our choice.
Now Get Back and Right Click to Mysql on Services and Click Start.
Now Mysql has started successfully
To get started
Start Mysql Shell
& type command
shell.connect({host: 'localhost',user: 'root'})
Now type password
To type sql commands:-
/sql
I had the same problem. I tried all of the answers above (and some from other websites). In the end, my issue was that my cache wasn't configured. I found that info in my error log and fixed it by changing the line in the file:
C:\MAMP\bin\apache\conf\extra\http-ssl.conf
There I removed the double quotes from the line:
SSLSessionCache "shmcb:/some/example/path/ssl_scache(512000)"
to:
SSLSessionCache shmcb:/some/example/path/ssl_scache(512000)
and saved with Ctrl+S and closed the file.
Here's the link that helped me:
https://wiki.apache.org/httpd/SSLSessionCache
I faced the same problem couple of times and each time the reason was different:
The solution that worked first time was that by "Abhishek Oza" which is same as that of "amey91" (see above)
The second time, my server was on a different port number than the default one(3036),so i was not able to connect.So I had to specify
the port number explicitly for making the connection which you can do
simply by writing: "mysql --host=127.0.0.1 --port=8081(specify your
port number here) mysql -u root -p"
In my case, which was a manual install using the .zip file.
I solved this by specifying the nonstandard MySQL and Data install locations in a my.ini.
https://dev.mysql.com/doc/refman/8.0/en/windows-create-option-file.html
Then I needed to run the data directory initialisation commands:
https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization-mysqld.html
Then running:
net start mysql
There is a possibility that your installation of MYSQL got corrupted. The best thing you can do is to search for MYSQL INSTALLER on your system and then run it again.
It will not download the mysql server again, it will just help you to set it up.
After that, edit your environment variables path and add the bin folder of your mysql to it.
By now, it should work.
In my case I have 2 different version of mysql in Windows OS and I solved the my problem by bottom step:
first stop all mysql service.
I create one config file in C:\mysqldata.cnf with bottom data(my mysql is in "C:/mysql-5.0.96-winx64" directory ):
[mysqld]
datadir = C:/mysql-5.0.96-winx64/data
port = 3307
then I run bottom command in cmd:
C:\mysql-5.0.96-winx64\bin\mysqld --defaults-file=C:\mysqldata.cnf --console
above step reference
then I create txt file in C:\resetpass.txt with bottom data:
UPDATE mysql.user SET password=PASSWORD('ttt') WHERE user='root';
then run mysqld with bottom command:
C:\mysql-5.0.96-winx64\bin\mysqld --init-file=C:\resetpass.txt --install mysql2 --console
net start mysql2
after these step you have one mysql service(with name mysql2) than run with port 3307.
I have 2 version of mysql with different user management tables(in version 5.0.96 user table difference with 5.5 version because of that I must be change table folder in first step)
you can run other mysql service with other port now(and you can run this steps with different datadir, service name and port for it again)
First make sure you have installed MYsql+Sqlyog(if you are using it.).
Start Registry Editor (Regedt32.exe).
Locate the following key in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
On the Edit menu, click Add Value, and then add the following registry value:
Value Name: MaxUserPort
Data Type: REG_DWORD
Value: 65534
This sets the number of ephemeral ports available to any user. The valid range is
between 5000 and 65534 (decimal). The default value is 0x1388 (5000 decimal).
On the Edit menu, click Add Value, and then add the following registry value:
Value Name: TcpTimedWaitDelay
Data Type: REG_DWORD
Value: 30
This sets the number of seconds to hold a TCP port connection in TIME_WAIT state before
closing. The valid range is between 30 and 300 decimal, although you may wish to check
with Microsoft for the latest permitted values. The default value is 0x78 (120 decimal).
Quit Registry Editor.
Reboot the machine.
I will advise to use first check if my.ini exist in mysql folder in c drive or in windows folder
mysqld -install (Service successfully installed)
mysqld --initialize (no prompt)
Also another advise is not to use mysql 8, since it is not compatible with wordpress or any other opensource yet, there are lot of changes between version 5 and version 8, so if you are using mysql please use version 5.x.
Steps to resolve the problem ->
Go to command prompt and at root of c (c:\ if environment variable-path is set)
type -> c:\>mysqld -install.
Then type -> c:\mysqld --initialize
Now create one .txt file (here in our example we are taking init.txt) at root of mysql(may vary according to your directory) ->c:\MySQL\init.txt.
Now open that .txt file(init.txt) and write in it ->
5.open Run console and write -> Services.msc
6.Then Services window will be open ,there select MYSQL,Double click It and press start
7.Finally open new Command prompt window and type at root of c (c:) ->c:\>mysqlsh
due to this shell will execute and here you are ready to go....
mysql -u root --port 3308
this one help me
port number from phpmyadmin default port is 3306

Can't connect to MySQL server on 'localhost' (10061) after Installation

I installed MySQL using mysql-installer-5.5.20.0.msi on Windows 7.
From the cmd window, I run "mysqlshow -u root -p". It asked for a password, then returned this error: "Can't connect to MySQL server on 'localhost' (10061)" This is a bad indication of partially failed/successful installation.
After reading the page, http://dev.mysql.com/doc/refman/5.5/en/windows-troubleshooting.html, it told me to find an error log (.err) in C:\Program Files\MySQL\MySQL Server 5.5\data. The directory exists but there is no log file.
I have a feeling this is related to the tight security of Windows 7, especially when installing a Unix based software. And yes, I am the Administrator on my PC.
Any help or suggestions is appreciated. And I can return a favor by answering Java and SQL query questions.
Please Try the following steps:
c:\mysql\bin>mysqld --install
c:\mysql\bin>mysqld --initialize
then press "Windows key + R" write "services.msc", run as admin
start MySQL service.
I also faced the same issue and resolved it by below setups:
Check the MYSQL service in the windows service. If it is there and not running then start it. It will solve your problem.
You can find the services window by navigating to windows Start menu and typing 'services' in the search bar. Select the 'Services' option with the cogs next to it (not the executable file) and the below window will appear. Scroll down to find 'MySql (version)'. When you select MySql you should see an option in the left pane that says 'Start the service'. Click this and a dialogue should appear to indicate Windows is attempting to start the service. Once started the left pane will now give you the option to stop, pause and restart the service and you will now be able to connect to your MySql from the windows cmd line.
If MYSQL service is not present in windows service then follow below setups.
a. Open cmd as administrator.
b. cd to C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin
c. Run the command:
C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin>mysqld.exe --install
d. Check the MySql in the windows service, And if it is not running, Start it by clicking on the service.
e. If your using XAMMP . Start MySQL at the XAMMP control Panel.
this issue is very to solve by windows server users
go to this path
C:\Program Files\MySQL\MySQL Server 5.1\bin
run this tool "MySQLInstanceConfig.exe"
and config the instatnce again and problem solved
The simple solution that worked for me is: change localhost to 127.0.0.1 in your database.yml or in your script if writing one.
Here, you need to make sure that the MySQL service is running is Windows. It might be possible that your MySQL service is not running cuurrently.
Open Services window by pressing Windows+R and entering services.msc
Find out MySQL right click and select start.
It works.
I had this error - stupid mistake was, I was using -p3307 to specify port, whereas I should have used -P3307, i.e. capital P. Small 'p' is for password arg :)
In Windows 7
press Windows+R it opens Run
Enter services.msc
Find out mysql right click and start
if mysql was not found
Run cmd as administrator
goto C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin directory(to go back use cd..) and type mysqld.exe --install
follow step 3
That's all
I solved this by adding the following arguments to the command line string:
mysql --user username --password password --host localhost --port 3306 databasename < "system path to .sql file"
Without the --host and --port arguments, especially if you change the port to let's say 3307, which is a non default value, will cause this error.
I got this error in command prompt when I tried to open MySQL from cmd "mysql -u root -p"
Can't connect to MySQL server on 'localhost:3306' (10061)
It was because I changed my port during the installation of MySQL community server as I had XAMPP server installed and running as well which was not allowing me to use the port 3306.
So basically I had 2 MySQL servers installed in my system.
MySQL community server.
XAMPP server.
If anyone had this same issue this is how I fixed it.
Step 1: Reconfigure MySQL server to port 3306
Step 2: Reconfigure XAMPP to use a different port other than 3306
Note: Stop the XAMPP server before following the steps.
Step 1: Reconfigure MySQL server to port 3306
Click Start and open MySql installer - community
Click on reconfigure button in front of MySql server
Type 3306 in port. Execute and complete the installation.
Step 2: Reconfigure XAMPP to use a different port other than 3306
Open XAMPP and change the port other than 3306 in two files
my.ini under MySQL
and php.ini under Apache
Now everything seems to be working fine for me. I was able to get into MySQL community server from cmd and I can use XAMPP server as well.
I have Windows 8.1 and I too had this problem. My teacher told me it was probably because my MySQL server had stopped running. She told me to go into the Computer Management utility (right click the lower-most left hand corner of the screen on Windows 8.1 to access Computer Management). Then under Services and Applications, open up the Services and find MySQL. You should be able to right-click on MySQL and restart it.
In Start Menu, search for "mysql". Among the results, you should see the "MySQL Installer - Community". Run it.
MySQL Installer window will show up as shown below. Find "MySQL Server" under Product and click on "Reconfigure" link.
The MySQL Installer will show up (same one you used for the first MySQL Server installation). Go through all the steps.
After the MySQL Installer was finished, I started the MySQL service again. This time, the "Startup Message Log" on The MySQL Notifier was showing that the server started successfully:
https://www.howtosolutions.net/2017/08/fixing-mysql-10061-error-after-migration-of-database-files/
This is the easiest solution and worked for me.
Go to where you downloaded
"mysql-installer-web-community-8.0.19.0.msi", file for installing
mysql.
Run this by double clicking on it. (No need to uninstall anything)
Click on "reconfigure" beside the MySql server.
Agree everything which comes in middle, provide password for root where asked.
Finish. That's it you're good to go.
For the 5.7 version, I had the same problem and a simple fix did the trick. As Installed the workbench 5.7 there was another "software" of sorts called the "MySQL Installer Community". I ran this and ran the "Reconfigure" for the MySQL server. It took about a minute and the problem was no longer there.
Hope it works!.(Keep in mind i was using the 5.7 version)
Just turn off the firewall and remove the instance configuration. Add a new instance for the server.![Disable Firewall][1]
Give he port number correctly as 3306 as default
Solution 1:
For 32bit:
Run "mysql.exe" from: C:\Program Files\MySQL\MySQL Server 5.6\bin
For 64bit:
Run "MySQLInstanceConfig.exe" from: C:\Program Files\MySQL\MySQL Server 5.6\bin
Solution 2:
The error (2002) Can't connect to ... normally means that there is no
MySQL server running on the system or that you are using an incorrect
Unix socket file name or TCP/IP port number when trying to connect to
the server. You should also check that the TCP/IP port you are using
has not been blocked by a firewall or port blocking service.
The error (2003) Can't connect to MySQL server on 'server' (10061)
indicates that the network connection has been refused. You should
check that there is a MySQL server running, that it has network
connections enabled, and that the network port you specified is the
one configured on the server.
Source: http://dev.mysql.com/doc/refman/5.6/en/starting-server.html
Visit it for more information.
For anyone who have the same problem of "Can't connect to MySQL server on 'localhost' (10061) " or "Can't connect to MySQL server on '127.0.0.1' (10061) ".
You can install "MySQL Installer" and this is the link http://dev.mysql.com/downloads/windows/installer/5.6.html
and this is a tutoriel for more help https://www.youtube.com/watch?v=AqQc3YqfelE
it works for me and i wish to work for you too.
I had the same error. I resolved in this way
Go to start- MySQL Installer-community and run again the installer as a re-configuration(you will be asked so).
Once asked if you want make MySQL instance to run as a Windows service, check the box.
In case would do not work, try unistalling and installing again, and check the box to run MySQL as Windows service.
From what I've gathered this means the mysql service (mysqld) isn't running.
First make sure it is installed as a windows service : Run
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --install
from the command line.
Next, start it up :
services.msc > MySQL > start
If it fails to restart, then you can follow these steps :
open the command line as an administrator :
cmd.exe > open as administrator
run "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" --verbose
it should fail and put the error log in a directory named data under C:\Program Files\MySQL\MysSQL Server 5.7\ . If it fails to create data for some reason, do it manually under that directory and try again. If you can figure out what's missing from what's in that log, then good, you're done.
If you've still got no luck, this is how I did it :
goto C:\ProgramData\MySQL and copy the file named my.ini to C:\Windows\
try to start the service again from the command line :
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" --verbose
If it doesn't display any error, than the service startup was successfull. If it's still not working, than delete that my.ini you just copied from C:\Windows and start the service from the command line once again.
it should work now
if it is showing error 2003 (HY000): Can't connect to MySQL server on localhost (10061) than
Search services.msc in run
goto mysql properties
copy the mysql service name
start cmd as administrator
write: net start mysqlservicename .i.e mysql57 or etc it will show mysql is starting.
For me, three steps solved this problem on windows 10:
I downloaded MySQL server community edition zip and extracted it in the D drive. After that I went to bin folder and did cmd on that folder. I followed the below steps and all works:
D:\tools\mysql-8.0.17-winx64\bin>mysqld -install
Service successfully installed.
D:\tools\mysql-8.0.17-winx64\bin>mysqld --initialize
D:\tools\mysql-8.0.17-winx64\bin>net start mysql
The MySQL service is starting...
The MySQL service was started successfully.
I too had this problem, its easy to solve:
Go to Control panel - System and maintenance - System - Advanced system settings - Environment variables - System variables - path - click edit - add
"c:\xampp\mysql\bin" - it should look like this :
\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime Alternative\QTSystem;c:\xampp\mysql\bin
And don't forget to start MySQL from control panel of Xampp.
I found the same error re occurring even after I tried all the above solutions given above. I had even tried version 5.7 and few more. Guys don't waste your time trying to fix it. Rather install version 5.5. It's working perfectly fine without any unnecessary error.
Well in my case I just opened services.msc using run and restarted 2 of the services related to mysql and it worked!
In case of Xampp Installation.
Go to your xampp installation and mysql folder, for my case: C:\xampp\mysql
Run the file "resetroot.bat" from cmd or explorer.
My installation started working!!!
The solution that fixed the issue was using the following steps:
In Start Menu, search for "mysql". Among the results, you should see the "MySQL Installer - Community". Run it.
MySQL Installer window will show up as shown below. Find "MySQL Server" under Product and click on "Reconfigure" link.
MySQL Installer Community
The MySQL Installer will show up (same one you used for the first MySQL Server installation). Go through all the steps.
After the MySQL Installer was finished, I started the MySQL service again.
Don't do useless stuff like reconfigure, stop MySQL and start MySQL in service.
Just reinstall the MYSQL server and again install it in your system.
Remember only uninstall MySQL server and nothing else.
All the problem will be solve automatically
The main reason for this kind of error is you might have uninstalled Mysql server application. Install it and then give it a go.
for who person that want use mysql or mariadb with out any error i suggest use version 5.5
just download a zip file mariadb-5.5.65-winx64.zip from https://downloads.mariadb.org/mariadb/5.5.65/ and to install follow this tutorial setp by step https://www.youtube.com/watch?v=uEPs6JsTZFc (this tutorial works well for version 5.5 too )
I had the same issue and basically resolved it by pointing to a specific port number that my MySQL server was running on. Below is the command. Please edit the code to fit your case i.e your port number,your mysql server username,your password.
mysql -u root -pYourMysqlRootPassword -P3307
Create the temp folder c:/mysqltmp
In my.ini file under [mysqld] add the line
tmpdir=c:/mysqltmp
Add full privileges to user NETWORK SERVICE for "C:\ProgramData\MySQL\MySQL Server X.Y\Data\ibdata1" file
Start service
These are steps for the same problem with MySQL5.7 and MySQL8.0 on Windows 10

#1130 - Host ‘localhost’ is not allowed to connect to this MySQL server

I accidentally changed the "host" value for the root user inside of the user table for mysql.
I need to change it back to localhost because I changed it to arancillary2125 (my other machines DNS name) but I cannot access mysql (from PHPMYADMIN or command prompt) due to "localhost" not having permissions any more.
I am running windows XP // apache //
I have tried the following solutions but they didn't work:
https://serverfault.com/questions/92870/1130-host-localhost-is-not-allowed-to-connect-to-this-mysql-server
Whoops.
This is on your local machine, I assume? At Start->Run, enter 'services.msc' and locate the MySQL service. Stop the service.
Edit:
Find your my.ini file (usually in C:\Windows or C:\mysql, etc). If you don't have one, create one. It's just a plain ASCII file.
Alter the file, add this in the [mysqld] section: skip-grant-tables.
On the command line, issue the command net start MySQL and wait a moment, the MySQL service should start.
Still on the command line, issue the command mysql -u root and hit "ENTER". You should be logged into MySQL as the 'root' user. Carefully change your grants and then logout. Stop the MySQL service / server. Re-edit your my.ini file and remove / comment out the skip-grant-tables line, and again start the server. Try to login as root again.
Just tested this on my Win XP Pro box.
This essentially has the effect of bypassing all the grant tables and thus doesn't bother to lookup whether you're supposed to access it from that machine or not.
MySQL reference manual : --skip-grant-tables option
So I had this problem aswell, happened all of a sudden with #1130 - Host ‘localhost’ is not allowed to connect to this MySQL server.
After searching and searching I can tell you that bdl solution is the way forward, once you can log back into the server you can change the permissions about and remove the line skip-grant-tables under your my.ini mysql config file.
I would have just upvoted bdl's post but im too new on the website to do that yet.
Recreate arancillary2125 (if even on an old desk top) and then access your DB that way.