I have installed percona server version 5.7 on my centos 7.Now when I try to issue following command to connect to the server.
access denied for user 'root'#'localhost'
I have tried to use the --skip-greant-tables to change the password and host from localhost to %.
I have tried changing the OS hostname to localhost.
I have also tried using --skip-name-resolve.
but still no chance.
any help appreciated
In Percona 5.7, the temporary password is stored in /var/log/mysqld.log so you can find it by:
grep 'temporary password' /var/log/mysqld.log
After that, you can start mysql
sudo systemctl start mysql
sudo /usr/bin/mysql_secure_installation
and use your temporary password to use.
After installing percona, you have to run these commands in order to set password for user root on mysql :
1- sudo systemctl start mysql
2- sudo mysql_secure_installation
Related
I'm re-installing MySQL (5.7.29) for Ubuntu Linux 18.04 LTS. I installed the package using apt & started the service without issue. I was not asked for a root password during the install and am not able to login.
I assume (from dev.mysql.com/doc/refman/5.7/en/default-privileges.html) that the data directory was initialized without my knowledge.
I used $tail /var/log/mysql/error.log -n 50 to see if an initial random pwd was created - no luck.
I also tried $mysql -u root --skip-password, which also fails due to access denial.
It's been a couple of years since I've used MySQL. What am I doing wrong? TY!
Ubuntu let the user login with the root account, this beahavior is default on MariaDB installations too:
sudo su -
mysql
If this don't resolve, you can start mysql without the tables associated with authentication:
sudo su -
systemctl stop mysql
mysqld --user mysql --skip-grant-tables &
mysql -h 127.0.0.1 --protocol tcp mysql -e "ALTER USER root#localhost IDENTIFIED BY 'mypassword'"
mysql -h 127.0.0.1 --protocol tcp -e 'shutdown'
systemctl start mysql
And try again ;)
I just installed MySQL Ver 14.14 Distrib 5.7.22 with Homebrew on my macOS v10.13.4.
I ran the command:
brew install mysql
After the installation completed, as directed by Homebrew, I ran the command:
mysql_secure_installation
and was returned the error: Error: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found
I tried a few things like changing default_authentication_plugin to mysql_native_password in the my.cnf file but it still throws the same error.
Next I tried running:
mysql_upgrade -u root
and I was thrown the same error again mysql_upgrade: Got error: 2059: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found while connecting to the MySQL server
Upgrade process encountered error and will not continue.
Any help is appreciated.
So, I found the running process of mysqld by sudo lsof -i tcp:3306 then I killed it using sudo kill -9 <PID>.
After this I tried mysql_secure_installation again, but ran into a new error :
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
After trying a few fixes for getting mysql.sock to work, I started the MySQL server with sudo mysql.server start then went ahead with mysql_secure_installation to set password for the root user.
This worked for me finally.
Note: Homebrew asks you to first do mysql_secure_installation before starting the MySQL server for the first time but that just made me run into endless loop of errors.
Restart the mysql server to take the changes in affect and try connecting via mysql with any mysql client.
Otherwise use docker
docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql --default-authentication-plugin=mysql_native_password
mysql -uroot --protocol tcp
Try in PWD
Related a question.
Authentication plugin 'caching_sha2_password' cannot be loaded
I figured out this should be an issue with the mysql version installed. Just as above you should first find then kill the mysqld process attached on port 3306
sudo lsof -i tcp:3306
sudo kill -9 <Peocess ID>
Then upgrade the mysql installation via brew, in this case:
brew upgrade mysql
This should solve it.Running mysql after the upgrade should start your server after the installation.
e.g mysql -u root -p [your password here]
I got this error in Sequel Pro trying to connect over SSH to an AWS Ubuntu server with MySQL installed locally.
I was using a non-root MySQL user and it gave me that error. It worked when I ran it with the root user and password.
I've installed mysql server on my Ubuntu 16.04 using this command:
user#samariter-ubuntu:~/dev$ sudo apt-get install mysql-server
I left the "root" pass blank. It went fine, no objections. However, when I try to start it, it refuses:
user#samariter-ubuntu:~/dev$ mysql
ERROR 1045 (28000): Access denied for user 'sasa'#'localhost' (using password: NO)
I must start it with sudo. Why is that? How can I solve it?
sudo service mysql-server : Install mysql server as a service. It downloads mysql server latest version available from apt repository.
sudo service mysql status : Check the status of your service
sudo service mysql start : start mysql server
sudo service mysql stop : stop mysql server
sudo service mysql restart : restart mysql service
To connect mysql server from mysql built in client, use the below command
$> mysql -u root -p
If your root password is empty, just press enter again. You will be prompted to
mysql >
First of all here you are not starting mysql. And this error is coming directly from mysql ubuntu has nothing in this. Your error says that mysql is already started but the the current user by which you have logged in Ubuntu is not found in the mysql's user table.
Typeing simple mysql means you want to log into mysql with current OS user that is sasa in your case.
try : mysql -uroot
Here root means mysql's root user not OS' root.
I am trying to run a local mysql server, on my own computer. I have lost the password that I initially set up. When I try to connect to mysql, I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I have therefore tried these steps to reset my MySQL password, but the line
mysql -u root mysql
returns the same error message:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
When running the command
mysqladmin -u root -p status
I get the following message:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I have been checking and the file mentioned (/var/run/mysqld/mysqld.sock) doesn't actually exist. I am not sure what is causing this.
I have tried a couple of solutions online including this, this, this and this but none of this solutions worked for me. I would like to add that mysql-server is installed on my machine.
Any help appreciated. Please accept my apologies if there is any confusion to the above statements. I tried to explain what is happening as much as I can, but I am a beginner and I am clueless as to what is happenening there.
1) Stop the mysql demon process using this command :
sudo /etc/init.d/mysql stop
2) Start the mysqld demon process using the --skip-grant-tables option with this command
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Because you are not checking user privs at this point, it's safest to
disable networking. In Dapper, /usr/bin/mysqld... did not work.
However, mysqld --skip-grant-tables did.
1) start the mysql client process using this command
mysql -u root
2) from the mysql prompt execute this command to be able to change any password
FLUSH PRIVILEGES;
3) Then reset/update your password
SET PASSWORD FOR root#'localhost' = PASSWORD('password');
4) If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
once have received a message indicating a successful query (one or more rows affected), flush privileges:
FLUSH PRIVILEGES;
Then stop the mysqld process and relaunch it with the classical way:
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
This is borrowed from https://help.ubuntu.com/community/MysqlPasswordReset , you can check also another method to reset mysql password.
Looks like your MySQL server is not running at all.
Can you check it?
service mysql status
You need to try restart it and make sure that you can stop and start it using
service mysql stop
service mysql start
If you have any errors post them here please.
Reinstalling mysql-server worked for me. (I am using mysql 5.7)
sudo wget http://repo.mysql.com/mysql-apt-config_0.8.9-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation
first kill user
sudo pkill -u <user>
Then install mysql server
sudo apt install mysql-server
Configure it
sudo mysql_secure_installation
Enter into mysql shell
sudo mysql
Even after I reset the root password with the following command I can not log to MySQL: (other commands listed to provide additional info)
# sudo dpkg-reconfigure mysql-server-5.1
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
# telnet 127.0.0.1 3306
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
# ps -Aw |grep mysql
26522 ? 00:00:00 mysqld
# /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
update:
# sudo mysqladmin -u root password 123
mysqladmin: connect to server at 'localhost' failed
it seems MySQL is not running properly
Update:
I am using MySQL 5.1 under Ubuntu.
It was OK until that I make some change in my.cnf to enable Remote Access. I undo my changes but problems did not solved! (Perhaps I forgot to undo some thing!)
update:
# service mysql status
mysql start/running, process 26650
# /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 26650
to set root password:
mysqladmin -u root password NEWPASSWORD
To recover it:
http://www.cyberciti.biz/tips/recover-mysql-root-password.html
My best guess is that if you have reconfigured / reinstalled MySQL, you need to login without a password, e.g.:
mysql -u root
or even
mysql
Edit: To see if the service is running, you could try:
service mysqld status
and if it is not running, try:
service mysqld start then check the status again.
It seems like MySQL is definitely not running. You can verify this with /etc/init.d/mysqld status or service mysqld status (don't link directly to the service command).
My spidey sense is telling me either your O/S or MySQL installation were performed improperly. It would help tremendously to know more about the (linux?) environment you're running, and how it was configured (or who configured it, in the case of PaaS).
Start as a service
sudo service mysql restart
to verify & check the service and the port
sudo netstat -tap | grep mysql
you should change the access permission. it should be 0644
sudo chmod 644 /etc/mysql/my.cnf
and then
sudo dpkg-reconfigure mysql-server-5.5