Install MySQL under Ubuntu 16.04

Execute the first command:

sudo apt-get install mysql-server

Insert picture description here
Enter y, a password setting interface will appear during download and installation:
Insert picture description here
enter the password you want to set, and then enter the confirm password again.

After completion as shown below:
Insert picture description here

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

Insert picture description here

Then execute the third command:

sudo apt-get install libmysqlclient-dev

Insert picture description here
Enter y, as shown in the figure below after completion:

Insert picture description here
After the installation is successful, you can use the following command to test whether the installation is successful:

sudo netstat -tap | grep mysql

Insert picture description here
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
Insert picture description here

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:
Insert picture description here
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.

Guess you like

Origin blog.csdn.net/zou_albert/article/details/114932025