First I did
debian@osboxes:~/Desktop$ mysql -u root -p Command 'mysql' not found, but can be installed with: sudo apt install mysql-client-core-8.0 # version 8.0.18-0ubuntu0.19.10.1, or sudo apt install mariadb-client-core-10.3 # version 1:10.3.20-0ubuntu0.19.10.1 then I installed
debian@osboxes:~/Desktop$ sudo apt install mysql-client-core-8.0 Now I do
debian@osboxes:~/Desktop$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) So now I check
debian@osboxes:~/Desktop$ sudo service mysql status Unit mysql.service could not be found. then I do
debian@osboxes:~/Desktop$ ps aux | grep mysql debian 4379 0.0 0.0 8896 916 pts/0 S+ 14:38 0:00 grep --color=auto mysql so it seems mysql service is running. but when I Try to login now
debian@osboxes:~/Desktop$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) debian@osboxes:~/Desktop$ I also tried.
debian@osboxes:~/Desktop$ systemctl restart mysql Failed to restart mysql.service: Unit mysql.service not found. debian@osboxes:~/Desktop$ sudo dpkg -l | grep -E 'mysql' ii libmysqlclient21:amd64 8.0.18-0ubuntu0.19.10.1 amd64 MySQL database client library ii mysql-client-core-8.0 8.0.18-0ubuntu0.19.10.1 amd64 MySQL database core client binaries ii mysql-common 5.8+1.0.5ubuntu2 all MySQL database common files, e.g. /etc/mysql/my.cnf debian@osboxes:~/Desktop$ Last week I had asked question mysql does not start after a reboot so I know I had installed mysql on this machine in problem. But still I face the problem so tried
debian@osboxes:~/Desktop$ sudo apt-get install mysql-server E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 4531 (unattended-upgr) - open (11: Resource temporarily unavailable) N: Be aware that removing the lock file is not a solution and may break your system. E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it? I also checked
debian@osboxes:~/Desktop$ systemctl -a | grep -iE 'mysql' there was no output. Also I do
debian@osboxes:~/Desktop$ sudo netstat -tap | grep mysql sudo: netstat: command not found then I do
debian@osboxes:~/Desktop$ sudo apt-get install net-tools debian@osboxes:~/Desktop$ sudo netstat -tap | grep mysql No output.
Now based on comments below I did
debian@osboxes:~/Desktop$ sudo rm /var/lib/dpkg/lock debian@osboxes:~/Desktop$ sudo dpkg --configure -a debian@osboxes:~/Desktop$ sudo systemctl restart mysql.service Failed to restart mysql.service: Unit mysql.service not found. Now try
debian@osboxes:~/Desktop$ sudo rm /var/cache/apt/archives/lock Now I reboot and then
debian@osboxes:~/Desktop$ ps aux | grep mysql debian 2403 0.0 0.0 8896 844 pts/0 S+ 15:10 0:00 grep --color=auto mysql debian@osboxes:~/Desktop$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) It is taking root password which I tried last week. I am not able to understand what should I check. I can't login. What should I check now? I am on Ubuntu 19.10
61 Answer
In addition to mysql client you need to install also mysql server.
I've added info from Ubuntu mysql
Installation
To install MySQL, run the following command from a terminal prompt:
sudo apt install mysql-server Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:
sudo netstat -tap | grep mysql When you run this command, you should see the following line or something similar:
tcp 0 0 localhost:mysql *:* LISTEN 2556/mysqld If the server is not running correctly, you can type the following command to start it:
sudo systemctl restart mysql.service Configuration
You can edit the /etc/mysql/my.cnf file to configure the basic settings -- log file, port number, etc. For example, to configure MySQL to listen for connections from network hosts, change the bind-address directive to the server's IP address:
bind-address = 192.168.0.5 Replace 192.168.0.5 with the appropriate address.
After making a change to /etc/mysql/my.cnf the MySQL daemon will need to be restarted:
sudo systemctl restart mysql.service 1