Execute the first command:
sudo apt-get install mysql-server
Enter y, a password setting interface will appear during download and installation:
enter the password you want to set, and then enter the confirm password again.
After completion as shown below:
Note: Generally, you can execute the first sentence above, but the two sentences below do not need to be executed!
The first mysql-clinet downloads the latest version of mysql by default. It does not require additional installation, but the lower version may cause problems, so here is one more step, and try to take into account the lower version.
The second libmysqlclient-de package contains mainly database library files and header files, which can be used for research embedded.
Execute the second command:
sudo apt-get install mysql-client
Then execute the third command:
sudo apt-get install libmysqlclient-dev
Enter y, as shown in the figure below after completion:
After the installation is successful, you can use the following command to test whether the installation is successful:
sudo netstat -tap | grep mysql
Next, you can open the database:
mysql -uroot -p
Then enter your password. If you
forget your password and need to modify it, please refer to: https://blog.csdn.net/zou_albert/article/details/114934826
Now to set mysql to allow remote access, first edit the file /etc/mysql/mysql.conf.d/mysqld.cnf:
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address = 127.0.0.1:
As shown in the figure below:
Save and exit, then enter the mysql service, and execute the authorization command:
grant all on *.* to root@'%' identified by '你的密码' with grant option;
flush privileges;
Then execute the quit command to exit the mysql service, and execute the following command to restart mysql:
service mysql restart
In this way, our database can be connected remotely.