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.
Related
am trying to deploy a website on a new server I install MYSQL using the command
sudo apt-get install mysql-server
After that I try to access the MYSQL command prompt using the command
sudo mysql -u root -p
it is giving me the error:
Access denied for user 'root'#'localhost' using password(NO).
Any idea on how to solve this? thanks!!
you have first to run
sudo mysql_secure_installation
after that you should have entered a password for root and the server is configured.
You can also use after that
sudo mysql
to get access with administrator rights and change passwords or add new users
The mysql command - which is the MySQL client library - doesn't require root privileges.
You should run it without sudo:
mysql -u root -p.
Then you should be asked to enter the password. As the docs say, the password should be known to you:
For installations using the MySQL APT repository or Debian packages directly downloaded from Oracle, you should have already assigned the root password yourself.
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 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
Today (2015-05-02) I upgraded my Linux system via apt-get update and
apt-get upgrade whereas mysql, mysqladmin and a lot more packages
have been updated. The mysql-server-5.5 runs and I can login and do all
the typical database operations but when I type:
user#ubuntu:~# mysqladmin proc
I get the following error:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
Formerly I could solve this issue by simple setting the mysql root password new.
This does not solve the issue anymore:
user#ubuntu:~# sudo dpkg-reconfigure mysql-server-5.5
How do I get the mysqladmin up again without reinstalling mysql?
Short version: If your MySQL user root needs a password to connect, it might be a good idea to have mysqladmin provide that password ;)
Longer version: Your MySQL user root seems to need a password to connect
setting the mysql root password new
But mysqladmin tries to connect without a password
'Access denied for user 'root'#'localhost' (using password: NO)'
And mysqladmin does that because you're not telling it otherwise ;)
mysqladmin, like other MySQL-related command line tools (mysql, mysqldump, mysqlshow etc.), offers options to provide such access data.
h: Which host to connect to. If not provided, localhost is assumed
u: Which user to connect as. If not provided, root is assumed
p: Which password to use. If not provided, no password is used
You should be able to use something like
mysqladmin -uroot -pmysupersecretpassword proc
(be aware that there's no space between the options and their values). You can also have MySQL ask you for the password like
mysqladmin -uroot -p proc
With that, MySQL should give you a prompt where you can enter your password.
Everything is going good and fine except for being able to get MySQL to work, Everything was working fine except status was failed.
MySQL Service Status
Try this if you are working in fedora 3x
sudo rm -rf /var/lib/mysql
sudo dnf install community-mysql-server
sudo systemctl start mysqld.service
After this try
sudo dnf reinstall community-mysql-server
After upgrading to Lion I can still start MySQL via System Preferences -> MySQL
When I try and login with the root user and password I was using on Snow Leopard I get this error via phpMyAdmin
#2002 Cannot log in to the MySQL server
Via the MySQL Query Browser however I get code 2003
If I try via Terminal with mysql -u root -p I get the error
-bash: mysql: command not found
Thanks for any help.
There was a problem with the socket and I had to change occurences of /var/mysql/mysql.sock to /tmp/mysql.sock as stated here http://birdchan.com/home/2011/07/20/osx-lion-mysql-sock-path/