Ubuntu20.04 install MySQL process


The whole process of installing MySQL based on ubuntu20.04 is recorded

1. Install MySQL

sudo apt-get update #Get the latest software source
sudo apt-get install mysql-server # install mysql

Start and shut down mysql

service mysql start #Start MySQL
service mysql stop #Close MySQL

2. Make MySQL configuration

start mysql

service mysql start

In order to prevent the bug of setting the password error in the next configuration, first set the root password (recommended execution, I personally report an error in the password every time I directly execute the next configuration)

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';

perform configuration operations

sudo mysql_secure_installation

After execution, you can choose according to the process. If the root password is not set, an error may be reported when the password is set in the second step of this process”Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server....“, it is recommended to return to the previous step first.

The follow-up is to follow the question of the automatic configuration program to make a yes or no choice. The content is roughly as follows:

#1. Ask if password plugin is installed
#2. Set a password for the root user or do you need to reset the password
#3. Whether to delete anonymous users
#4. Whether to prohibit the root administrator from logging in remotely
#5. Whether to delete the test database and cancel access to it
#6. Whether to refresh the authorization table, so that the initialized settings will take effect immediately

After all selected, it will display All done

Check mysql running status

netstat -tap | grep mysql

3. Configure remote login (if needed)

At this time, mysql does not allow remote login. If you connect from other addresses through tools such as navicat, an error will be reported.Host is not allowed to connect to this MySQL server, if the business needs it, it needs to be released.

First log in to mysql

mysql -u root -p 

After entering the password, enter the mysql command and execute the following content

#Open mysql library
use mysql
#View access domain settings
select host from user where user = 'root';
#Modify the access domain, change localhost to%
update user set host ='%' where user = 'root';
#Reload permissions
flush privileges;

Modify the bind ip in the mysql configuration file

vim /etc/mysql/mysql.conf.d/mysqld.conf

find insidebind-address = line, comment it out, save and exit.

restart mysql

service mysql stop
service mysql start

Recommended Today

Detailed explanation of Redis data structure (2) – dictionary dict in redis

prerequisite knowledge Dictionaries, also known as symbol tables or maps, can be simply understood asKey-value pair key-value。For example, Java’s common collection class HashMap is used to store key-value pairs.The key (key) in the dictionary is unique. Due to this feature, we can find the corresponding value (value) according to the key (key), or perform update […]