Stopping MySQL Server from command line on Windows 7 - mysql

I am trying to shutdown the mysql server from command line.
MySQL root password is "" (blank)
C:\Users\Jigar>"C:\mysql\bin\mysqladmin.exe" -u root -p shutdown
Enter password:
When I just press enter, it stops the server.
But when I don't specify -p, I am not able to stop the server:
C:\Users\Jigar>"C:\mysql\bin\mysqladmin.exe" -u root shutdown
C:\mysql\bin\mysqladmin.exe: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: YES)'
I am actually writing a program to stop the server. In mac I was able to stop the server with blank root password without specifying -p in the command. But I am not able to do the same in Windows.

Related

Cannot connect to Database server through mysqlworkbench

All of the sudden, I can't connect to the mysql service instance setup in MWB. I get this error:
Failed to Connect to MySQL at localhost:3306 with user root Unknown
MySQL server host 'localhost' (0)
I can start and stop the server through the MySql system preferences. I can also log into the server through the command line:
mysql -u root -p -h 127.0.0.1 -P 3306
Any ideas how to fix this? The following had to effect:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
"password" is currently the root user password.

How to change MySQL root password via a file?

How do I change the MySQL root password in ubuntu server via a file?
The file may be any shell script or normal text file.
My try:
Normally the below command, in the terminal, changes the password for newly installed mysql.
mysqladmin -u root password 'newpass'
But while doing it via file it's showing the bellow error.
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
So can someone help me to do so.
Stop the MySQL Server: sudo /etc/init.d/mysql stop
Start the mysqld configuration: sudo mysqld --skip-grant-tables
Login to MySQL as root: mysql -u root mysql
Replace YOURNEWPASSWORD with your new password:
UPDATE
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: This method is not regarded as the most secure way of resetting the password, however, it works.
If you have never assigned a root password for MySQL, the server does not require a password at all for connecting as root follow :
Resetting Permissions

MySQL - Can't Log In - Access Denied - Brand New Installation (OpenWRT)

I installed MySql on OpenWRT successfully without any errors - see below but I am having issues logging in - it's telling me access denied. But according to everything I found on the Internet, the default user name is root and there is no password so I must be a special case.
Please take a look below:
root#OpenWrt:~# mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h OpenWrt password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/scripts/mysqlbug script!
root#OpenWrt:~#
I then start the server:
root#OpenWrt:~# /usr/bin/mysqld &
root#OpenWrt:~# 160104 10:48:04 [Note] Event Scheduler: Loaded 0 events
160104 10:48:04 [Note] /usr/bin/mysqld: ready for connections.
Version: '5.1.73' socket: '/var/run/mysqld.sock' port: 5158 Source distribution
Then I try to log on:
root#OpenWrt:~# mysql
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
root#OpenWrt:~#
I then tried:
root#OpenWrt:~# mysqladmin -u root -p root
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: YES)'
root#OpenWrt:~#
In the above, for password I entered: "root" when it asked me for it.
I also tried leaving it blank but no luck. I also tried ('new-password').
I have spent hours searching this site and other sites but none of the suggestions I've tried work. Also, in my case, mysqld_safe does not appear to be installed (and I don't believe it's available for OpenWRT).
Point of references: http://forums.mysql.com/read.php?34,140320,140324, http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html, How to find out the MySQL root password, 'Access denied for user 'root'#'localhost' (using password: NO)' and many other of which I lost track -- too many and none of them work.
Update
Please take a look below:
root#OpenWrt:~# /usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
root#OpenWrt:~# /usr/bin/mysqladmin -u root password 'root'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
root#OpenWrt:~# /usr/bin/mysqladmin -u root password 'admin'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
root#OpenWrt:~# mysqladmin reload
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
root#OpenWrt:~# /usr/bin/mysqladmin -u root password
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
Have you tried following the instructions it gives you after install? specifically:
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
It could be the case that there is no root user created or some such.
Also perhaps force a reload of the database, especially once you add a user to force it to reload the user table:
mysqladmin reload
HTH
As mysql log file is suggesting, try below comamnd-
/usr/bin/mysqladmin -u root password 'your_root_password';
Even you can try without password as per below and set root password from mysql prompt-
mysql -uroot
I fixed it! I found what the problem was!
MySql looks for the user name in its tables and if it keeps telling me "access denied" it means the "root" user most likely doesn't exist (since it is a brand new installation). So I removed the entire installation and deleted "everything" MySql associated.
I ran the install script with the --help option and check this out!
--user=user_name The login username to use for running mysqld. Files
and directories created by mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
Then, I ran the script again but I passed the --user=root parameter:
mysql_install_db --user=root
root#OpenWrt:~# mysql_install_db --user=root
Voila! :)
root#OpenWrt:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Having said this, now I am thinking, I could have probably searched the databases with a notepad or some sort of database editor since they are in ASCII format and see if I can find an entry for user root but the files are gone now. Either way, this is the solution!

Access denied for user 'root#localhost' (using password: YES)

When install MySQL in Cent OS, it is installed correctly.
After installation,I type this command in terminal.
/etc/init.d/mysqld start
It shown error and I typed password as 'new-password'. In this time, I found this error.
[root#datsvr018 bin]# /etc/init.d/mysqld start
Starting mysqld: [ OK ]
[root#datsvr018 bin]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current password
for the root user. If you've just installed MySQL, and you haven't set
the root password yet, the password will be blank, so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Right after install MySQL, you need to run mysqladmin to set root password.
mysqladmin -u root password NEWPASSWORD

MYSQL can't start service on Windows 7

EDIT: This happened most of the times, due to power failure.
Two things which worked for me.
1. Knowing how to change root password in MySQL, and taking backup of databases.
2. Install MYSQL as service.
C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install
I had done clean installation of MYSQL 5.6 few days ago.
On first day everythng was fine. I could access city and world tables.
On next day I started getting below errors. Some were I read to run mysqld at admin level.
And it solved problem, but I couldn't access city and world table anymore.
On third day. I am getting only this errors.
Note: MYSQL service running previously fine, when firewall, antivirus (avast) and apache was running.
When run on admin mode :
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: ***********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: *
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password:
ERROR 1049 (42000): Unknown database 'localhost'
When run on user mode (who is admin also) :
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: ***********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: *
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password:
ERROR 1049 (42000): Unknown database 'localhost'
Not able to start MYSQL Service from Control Panel\All Control Panel Items\Administrative Tools\Service
Error Message ; WIndows could not start the MYSQL56 service on Local Computer
Error 1067 THe process terminated unexpectedly
Regards : Msinfo
You need to use "-h" before "localhost" if you want to specify a host, otherwise just remove "localhost" and it should work fine, considering a running server on your system.
Also, MySQL server is "mysqld.exe" not "mysql.exe". mysqld (d stands for daemon) is the server which should run in background and does the actual stuff like creating tables,DBs etc. But mysql.exe just connects to the server and helps you to execute SQL queries. mysql.exe is just an interface to connect to server. If you want to know why your server (windows service in your case) is not starting, you should see the XXX.log in your MySQL server installation folder under Program Files.
try by creating the database in MySql by the respective name "localhost"
eg: create database localhost;
by doing this you can clear the below error
ERROR 1049 (42000): Unknown database 'localhost'
hope i am correct
Thanks,
Daya