Problem-solving process record: Error connecting to mysql database

Problem Description:

报错:ERROR 2026 (HY000): SSL connection error: unknown error number

 Change the input method mysql -h 127.0.0.1 -P3306 -uroot -p --ssl-mode=DISABLED

报错:ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

 This error is due to the encryption method

First of all, everyone may know:

  • The default encryption method of mysql5 is  my_native_password
  • The default encryption method of mysql8 is  caching_sha2_password

Solution

Edit the my.cnf configuration file (not used)

vim /etc/my.cnf

 After inputting, an error is reported. The following information is estimated to be a prompt: vim has not been installed, and the vim installation package already exists. Among the listed packages, you can use the sudo apt-get install vim command to install,

Enter sudo apt-get install vim and the following error occurs

Replace the mirror source and enter the update below to update

Enter sudo gedit /etc/apt/sources.list to enter, comment all inside at the end, copy the following code to the bottom and save

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse

sudo apt-get update
sudo apt-get upgrade

Enter sudo apt-get install vim and another error occurs, the error is as follows

 Type: sudo apt-get install ctags

 Then enter sudo apt-get install vim, enter y to download as shown below

After typing, enter mysql -h 127.0.0.1 -u root -p

报错ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111) 

 Enter service mysql status to view the status of mysql

not turned on

Enter docker ps -a and find that the mysql port does not indicate that mysql has not started successfully

 enter

docker run -p 3306:3306 -v ~/book/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql

Enter docker ps -a to view

 mysql started successfully

Install the MySQL client program, sudo apt-get install mysql-client-core-5.7 After the installation is complete, enter

mysql -h 127.0.0.1 -u root -p

 

Guess you like

Origin blog.csdn.net/qq_61897141/article/details/128348913