install mysql 5.7 to Linux Mint 19.0

install

lwk@qwfys:~$ apt install mysql-server mysql-client mysql-workbench
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libgdal20 libmysqlclient20 libmysqlcppconn7v5 mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-workbench-data python-mysql.connector
Suggested packages:
  mailx tinyca
Recommended packages:
  proj-bin libhtml-template-perl ttf-bitstream-vera mysql-utilities
The following NEW packages will be installed:
  libgdal20 libmysqlclient20 libmysqlcppconn7v5 mysql-client mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7 mysql-workbench mysql-workbench-data python-mysql.connector
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.3 MB/36.4 MB of archives.
After this operation, 278 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 mysql-common all 5.8+1.0.4 [7,308 B]
Get:2 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libgdal20 amd64 2.2.3+dfsg-2 [5,099 kB]
Get:3 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libmysqlcppconn7v5 amd64 1.1.9-1 [173 kB]
Get:4 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 mysql-workbench-data all 6.3.8+dfsg-1build3 [1,281 kB]
Get:5 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python-mysql.connector all 2.1.6-1 [98.1 kB]
Get:6 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 mysql-workbench amd64 6.3.8+dfsg-1build3 [8,628 kB]                                                                                                                            
Fetched 15.3 MB in 11s (1,332 kB/s)                                                                                                                                                                                                          
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 335419 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.8+1.0.4_all.deb ...
Unpacking mysql-common (5.8+1.0.4) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Setting up mysql-common (5.8+1.0.4) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 335575 files and directories currently installed.)
Preparing to unpack .../0-mysql-server-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Selecting previously unselected package libmysqlclient20:amd64.
Preparing to unpack .../1-libmysqlclient20_5.7.23-0ubuntu0.18.04.1_amd64.deb ...
Unpacking libmysqlclient20:amd64 (5.7.23-0ubuntu0.18.04.1) ...
Selecting previously unselected package libgdal20.
Preparing to unpack .../2-libgdal20_2.2.3+dfsg-2_amd64.deb ...
Unpacking libgdal20 (2.2.3+dfsg-2) ...
Selecting previously unselected package libmysqlcppconn7v5:amd64.
Preparing to unpack .../3-libmysqlcppconn7v5_1.1.9-1_amd64.deb ...
Unpacking libmysqlcppconn7v5:amd64 (1.1.9-1) ...
Selecting previously unselected package mysql-client.
Preparing to unpack .../4-mysql-client_5.7.23-0ubuntu0.18.04.1_all.deb ...
Unpacking mysql-client (5.7.23-0ubuntu0.18.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../5-mysql-server_5.7.23-0ubuntu0.18.04.1_all.deb ...
Unpacking mysql-server (5.7.23-0ubuntu0.18.04.1) ...
Selecting previously unselected package mysql-workbench-data.
Preparing to unpack .../6-mysql-workbench-data_6.3.8+dfsg-1build3_all.deb ...
Unpacking mysql-workbench-data (6.3.8+dfsg-1build3) ...
Selecting previously unselected package python-mysql.connector.
Preparing to unpack .../7-python-mysql.connector_2.1.6-1_all.deb ...
Unpacking python-mysql.connector (2.1.6-1) ...
Selecting previously unselected package mysql-workbench.
Preparing to unpack .../8-mysql-workbench_6.3.8+dfsg-1build3_amd64.deb ...
Unpacking mysql-workbench (6.3.8+dfsg-1build3) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for desktop-file-utils (0.23+linuxmint3) ...
Setting up mysql-server-core-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2) ...
Processing triggers for shared-mime-info (1.9-2) ...
Setting up libmysqlclient20:amd64 (5.7.23-0ubuntu0.18.04.1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
Setting up python-mysql.connector (2.1.6-1) ...
Setting up mysql-client-core-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Setting up mysql-workbench-data (6.3.8+dfsg-1build3) ...
Setting up libgdal20 (2.2.3+dfsg-2) ...
Setting up libmysqlcppconn7v5:amd64 (1.1.9-1) ...
Setting up mysql-workbench (6.3.8+dfsg-1build3) ...
Setting up mysql-client-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Setting up mysql-client (5.7.23-0ubuntu0.18.04.1) ...
Setting up mysql-server-5.7 (5.7.23-0ubuntu0.18.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (5.7.23-0ubuntu0.18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for ureadahead (0.100.0-20) ...
lwk@qwfys:~$ 

secure installation

lwk@qwfys:~$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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
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) : y
Success.

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) : n

 ... skipping.
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
Success.

All done! 
lwk@qwfys:~$ sudo mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             | *8E816125987DDB80C04529D7453B25FD614DF4F1 | mysql_native_password | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *D45B5A803602EC3632EC1026D9A8B8317B71FB1A | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)
mysql>

add user lwk

mysql> CREATE USER 'lwk'@'%'  IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.04 sec)

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             | *8E816125987DDB80C04529D7453B25FD614DF4F1 | mysql_native_password | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *D45B5A803602EC3632EC1026D9A8B8317B71FB1A | mysql_native_password | localhost |
| lwk              | *8E816125987DDB80C04529D7453B25FD614DF4F1 | mysql_native_password | %         |
+------------------+-------------------------------------------+-----------------------+-----------+
5 rows in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'lwk'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> 

Log in as user lwk

lwk@qwfys:~$ mysql -ulwk -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

这个时候,所有的账号只能从本地访问,要想从外部主机访问,还需要将文件/etc/mysql/mysql.conf.d/mysqld.cnf中的"bind-address = 127.0.0.1"一行注释掉。

注释掉以后,重启服务:

lwk@qwfys:~$ sudo systemctl restart mysql.service

转载于:https://my.oschina.net/qwfys200/blog/1922473

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值