linux 下安装解压tar.gz 方式安装mysql5.7版
程序员文章站
2022-05-28 10:45:29
...
检查之前是否卸载干净mysql,参考之前的一篇博客
1.下载安装文件
http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.7/ mysql5.7的 各个版本,选择linux-glibc2.12-x86_64版本
[[email protected] tmp]# wget http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
2.解压安装包并重命名
[[email protected] tmp]# tar -xzvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[[email protected] local]# mv mysql-5.7.23-linux-glibc2.12-x86_64 mysql
3.在/user/local/mysql下创建data目录
[[email protected] mysql]# mkdir data
4.创建用户mysql
# useradd -M -s /sbin/nologin mysql
5.安装mysql服务
同时会生成初始的root密码
[[email protected] bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
2018-09-14T01:29:19.943304Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-14T01:29:22.889460Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-09-14T01:29:23.344284Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-09-14T01:29:23.467257Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9c5a6727-b7bd-11e8-950d-00163e000746.
2018-09-14T01:29:23.478545Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-09-14T01:29:23.481101Z 1 [Note] A temporary password is generated for [email protected]: WtuINdwKl9/I
[[email protected] bin]#
6.设置开机启动
[[email protected] mysql]# ls
bin COPYING data docs include lib man README share support-files
[[email protected] mysql]# cd support-files/
[[email protected] support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[[email protected] support-files]# cp mysql.server /etc/init.d/mysql
[[email protected] support-files]# chmod +x /etc/init.d/mysql
[[email protected] support-files]# chkconfig --add mysql
[[email protected] support-files]# chkconfig --list mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7.mysql 服务开启
[[email protected] support-files]# service mysql start
Starting MySQL [ OK ]
8.进入mysql中
密码为第四步中生成的初始化密码
[[email protected] bin]# ./mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23
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> set password=password("修改密码");
Query OK, 0 rows affected, 1 warning (0.00 sec)
9.给外网ip配置访问权限
mysql> grant all privileges on *.* to 'root'@'%' identified by '[email protected]@2018';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
其他
1.mysql -u root -p -bash:mysql:command not found 时解决方式
[[email protected] bin]# mysql -u root -p
-bash: mysql: command not found
[[email protected] bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin
[[email protected] bin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.23 MySQL Community Server (GPL)
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>
2.修改查看mysql的最大连接数
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.00 sec)
mysql> set globla max_connections=500;
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 'max_connections=500' at line 1
mysql> set global max_connections=500;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 500 |
+-----------------+-------+
1 row in set (0.00 sec)
3.查看mysql的所有远程连接情况
mysql> show processlist;
+----+------+--------------------+------+---------+------+----------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+--------------------+------+---------+------+----------+------------------+
| 6 | root | 112.17.87.192:2859 | NULL | Sleep | 821 | | NULL |
| 7 | root | localhost | NULL | Query | 0 | starting | show processlist |
+----+------+--------------------+------+---------+------+----------+------------------+
2 rows in set (0.00 sec)
mysql>
4.创建数据库导入sql脚本
mysql> create database ds9;
Query OK, 1 row affected (0.00 sec)
mysql> use ds9;
Database changed
mysql> set names utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> source /data/temp/ds9_v1.0_20180523.sql
Query OK, 0 rows affected (0.07 sec)
Query OK, 0 rows affected (0.07 sec)
Query OK, 0 rows affected (0.08 sec)
Query OK, 0 rows affected (0.06 sec)
Query OK, 0 rows affected (0.07 sec)
Query OK, 0 rows affected (0.07 sec)
Query OK, 0 rows affected (0.08 sec)
Query OK, 0 rows affected (0.06 sec)
Query OK, 0 rows affected (0.06 sec)
Query OK, 0 rows affected (0.08 sec)
Query OK, 0 rows affected (0.06 sec)
Query OK, 0 rows affected (0.05 sec)
Query OK, 0 rows affected (0.05 sec)
上一篇: mysql5.7解压版安装
下一篇: Linux下安装MySQL5.7版本
推荐阅读
-
VMware中linux环境下oracle安装图文教程(二)ORACLE 10.2.05版本的升级补丁安装
-
Windows10下mysql 8.0.12解压版安装配置方法图文教程
-
centos的安装与配置,Linux下基本命令、权限控制,解压缩文件以及软件的安装与卸载
-
centos7下yum方式安装MySQL5.7
-
Win10下免安装版MySQL5.7的安装和配置
-
CentOS7安装mysql5.7解压缩版简明教程
-
MySQL5.7.25(解压版)Windows下详细的安装过程
-
Windows10下mysql 8.0.12 解压版安装图文教程
-
Linux下二进制方式安装mysql5.7版本和系统优化的步骤
-
Linux下rpm、yum和源码三种安装方式详细介绍