Install MySQL under Ubuntu 18.04 (graphic tutorial)

Tip: The following operations are performed under root authority.

Check if MySQL is installed:

dpkg -l | grep mysql

Install MySQL:

apt install mysql-server

After the installation is complete, you can use the following command to check whether the installation is successful:

netstat -tap | grep mysql

After checking the above command, if you see that the mysql socket is in the LISTEN state, the installation is successful.

You can log in to the mysql database through the following command:

mysql -u root -p

Then through show databases; you can view all current databases.

Next, in order to ensure the security and normal operation of the database, the database is initialized. This initialization operation involves the following 5 steps.

(1) Install the verification password plug-in.

(2) Set the special password of the root administrator in the database.

(3) Then delete the anonymous account and use the root administrator to log in to the database remotely to ensure the security of the business running on the database.

(4) Delete the default test database and cancel a series of access permissions for the test database.

(5) Refresh the authorization list to make the initialized settings take effect immediately.

For the above steps of database initialization, I made a simple note next to the output information below.

root@ubuntu-virtual-machine:~# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? #Do you want to install the verification password plugin?

Press y|Y for Yes, any other key for No: N # Here I choose N
Please set the password for root here.

New password: #Enter the database password to be set for the root administrator

Re-enter new password: #Enter the password again

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No): y #Delete anonymous accounts
Success.

Normally, root should only be allowed to connect from
‘localhost’. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No): N #Forbid root administrator to log in remotely, here I did not prohibit

… skipping.
By default, MySQL comes with a database named ‘test’ that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No): y #Delete the test database and cancel access to it
– Dropping test database…
Success.

– Removing privileges on test database…
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No): y #Refresh the authorization table to make the initialized settings take effect immediately
Success.

All done!

Check the mysql service status:

systemctl status mysql

The following results show that the mysql service is running normally:

Use the mysql -u root -p command again, enter the password you just set at Enter password: and press Enter to enter the mysql database.

Use the use mysql; command to open the database named by mysql, and display the tables of the current database: show tables; query the data in the user table: select * from user; (the user table contains all the account information of the mysql database)

Now to configure mysql to allow remote access, first edit the /etc/mysql/mysql.conf.d/mysqld.cnf configuration file:

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

Comment out bind-address = 127.0.0.1

Save and exit, then enter the mysql database and execute the authorization command:

mysql -u root -p
mysql> grant all on *.* to root@'%' identified by 'Your password'with grant option;
mysql> flush privileges; #Refresh permissions
mysql> exit

Then execute the exit command to exit the mysql service, and then execute the following command to restart mysql:

systemctl restartmysql

Now under Windows, you can use Navicat graphical tools to remotely connect to the MySQL database under Ubuntu, and enter the password for the newly authorized remote permissions.

Share here by the way: Navicat for MySQL 10.1.7 installation package

Link: https://pan.baidu.com/s/12P1BcvQsRetBY0jGIvwILw&shfl=shareset Extraction code: 8bft

OK, the installation of MySQL under Ubuntu 18.04 has been completed.

During the operation, I encountered the following error:

E: Unable to obtain lock /var/lib/dpkg/lock-frontend – open (11: The resource is temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

Solution, refer to the article: https://www.zalou.cn/article/172460.htm

to sum up

The above is the method of installing MySQL under Ubuntu 18.04 introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!

Recommended Posts

Install MySQL under Ubuntu 18.04 (graphic tutorial)
Install mysql under Ubuntu 16.04
Install MySQL under Ubuntu
Ubuntu 16.04 installation graphic tutorial under VMware 12
Ubuntu20.04 steps to install cuda10.1 (graphic tutorial)
Ubuntu18.04 install Nvidia graphics driver tutorial (graphic)
Install node.js under Ubuntu
Install mysql5.7 under CentOS7
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Install mysql on Ubuntu 14.04
Ubuntu16.04 install Mongodb tutorial
2018-09-11 Install arduino under Ubuntu
Centos7 install Mysql8 tutorial
Ubuntu19 install MySQL pit
Install mysql under Centos 7
Install ROS under ROS Ubuntu 18.04[2]
Install mysql5.1 under CentOS6.5
Install Yarm-PM2 under Ubuntu
ubuntu14.04 install jdk1.8 tutorial
Windows10 install ubuntu20.04 dual system detailed graphic tutorial
Install MySQL under Linux (CentOS 7)
Install server-side Shadowsocks under Ubuntu 16.04
ubuntu19.04 installation tutorial (graphic steps)
5.1. CentOS@ install JDK1.8 graphic tutorial
Install rgl package under Ubuntu
Install Mesos tutorial under CentOS7
How to install MySQL on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
Install and configure MySQL on Ubuntu
How to install mysql in Ubuntu 14.04
Install JDK1.8 original under Ubuntu Kylin
Small tool: install screenshot tool under ubuntu
Install nodejs and npm under Ubuntu 16.04
Ubuntu install MySQL password initialization problem
Ubuntu 20.04 CUDA&cuDNN installation method (graphic tutorial)
How to install mysql in Ubuntu 14.04
How to install MySQL on Ubuntu 14.04
How to install Audacious under Ubuntu
How to install Tensorflow under ubuntu 16.04
Compile and install QEMU under Ubuntu
Ubuntu16.04 mirror complete installation tutorial under VMware
Install mysql8.0.13 version under Linux CentOS7 system
Install YouCompleteMe plugin for vim under Ubuntu
Install PyTesser under ubuntu 14.04 for OCR recognition
Install Ubuntu with Parallels Desktop under Mac
Three ways to install software under Ubuntu
Ubuntu 18.04 install Odoo14 tutorial through source code
How to change MySQL password under Ubuntu
Install utility software collection under Ubuntu system
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
ubuntu18.04 install python2
Ubuntu operation tutorial
ubuntu12.04 install python3
Ubuntu install guide
ubuntu install nodejs
ubuntu 16 install asp.net
ubuntu install leanote