1.下载mysql-server_5.7.26-1ubuntu14.04_amd64.deb-bundle.tar安装包
下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads
2.解压文件
3.依次安装mysql
sudo dpkg -i mysql-common_5.7.26-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.26-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.7.26-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.7.26-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.26-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-client_5.7.26-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-source_5.7.26-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-server_5.7.26-1ubuntu14.04_amd64.deb
sudo apt-get -f install
4.启动mysql
sudo service mysql start
5.查看mysql启动状态
sudo netstat -tap|grep mysql
6.查看mysql监听
sudo netstat -anpt |grep mysql
7.创建用户并设置远程访问
7.1创建用户并授权
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> grant all privileges on *.* to test@'%'identified by "test" with grant option;
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> seletc host,user,password from user;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'seletc host,user,password from user' at line 1
mysql> select host,user,password from user;
+---------------+------------------+-------------------------------------------+
| host | user | password |
+---------------+------------------+-------------------------------------------+
+---------------+------------------+-------------------------------------------+
6 rows in set (0.00 sec)
7.2修改端口
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
修改后:
重启mysql
sudo service mysql stop #停止mysql
sudo service mysql start #启动mysql