Build MySQL environment on cloud server Ubuntu

1. Install MySQL
sudo apt-get update
sudo apt-get install mysql-server
When installing, you will be prompted to enter a password and enter the password twice

2. Configure MySQL

运行安全脚本。
sudo mysql_secure_installation
输入设置的密码

3. Test MySQL
systemctl status mysql.service

如下输出正常:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor 
preset: en Active: active (running) since Wed 2016-11-23 21:21:25 
UTC; 30min ago Main PID: 3754 (mysqld) Tasks: 28 Memory: 142.3M  
CPU: 1.994s CGroup: /system.slice/mysql.service └─3754 /usr/sbin
/mysqld

If mysql is not running, start mysql:

sudo systemctl mysql start

Check the version of mysql:

mysqladmin -p -u root version

如下输出正常:
mysqladmin  Ver 8.42 Distrib 5.7.16, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights 
reserved.
Oracle is a registered trademark of Oracle Corporation and/or its 
owners.
Server version 5.7.16-0ubuntu0.16.04.1 Protocol version 10 
/mysqld.sock Uptime: 30 min 54 sec
Threads: 1 Questions: 12 Slow queries: 0 Opens: 115 Flush tables: 
1 Open tables: 34 Queries per second avg: 0.006

4. Set up remote access
Edit the mysqld.cnf document
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf and
comment out bind-address = 127.0.0.1:

5. Set the authorized account
grant all on . to account@'%' identified by 'password' with grant option;

6. Restart mysql
service mysql restart

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324882706&siteId=291194637