CENTOS 7
MYSQL 5.7
下载MySQL 5.7
https://dev.mysql.com/downloads/mysql/5.7.html#downloads

cd /usr/local/src
解压安装和配置
文件夹 文件夹内容
/usr/bin 客户端和脚本
/usr/sbin Mysqld服务器
/var/lib/mysql 日志文件和数据库
/usr/share/info 信息格式的手册
/usr/share/man Unix手册
/usr/include/mysql 头文件
/usr/lib/mysl 库
/usr/share/mysql 错误信息、字符集、示例配置文件等
源代码安装需要一些开发工具
(1)cmake http://www.cmake.org/
(2)make http://www.gun.org/software/make/ 3.7.5+
(3)ansi c++ gcc 4.2.1+
(4)perl 运行test版本所需要
(5)rpm rpm包管理器,rpmbuild 工具
yum list installed mysql
yum list installed mariadb
rpm -qa | grep "mysql|mariadb"
rpm -e --nodeps mariadb
rpm -e --nodeps mysql
yum install -y cmake make gcc-c++ perl wget
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -P /usr/local/src
tar -xvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.28-linux-glibc2.12-x86_64/ mysql
mkdir /data && mv mysql /data/mysql
groupadd mysql
useradd mysql -g mysql
mkdir -p /data/mysql && cd /data
chown -R mysql
chgrp -R mysql
cp /etc/my.cnf /etc/my.cnf.bak
echo '[mysqld]
basedir=/data/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
user=mysql
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
lower_case_table_names = 1
port = 3306
tmpdir = /tmp' > /etc/my.cnf
cd /data/mysql/
./bin/mysqld --initialize --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data
.....
2019-10-11T04:42:25.409894Z 1 [Note] A temporary password is generated for root@localhost: N9YJ7swptw.X
cd /data/mysql/support-files/
./mysql.server start
Starting MySQL.Logging to '/data/mysql/data/localhost.localdomain.err'.
SUCCESS!
cd /data/mysql/
./bin/mysql -uroot -p'N9YJ7swptw.X'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.28
Copyright (c) 2000, 2019, 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.
登录成功设置root密码:
mysql> set password=password('Huixst.9');
Query OK, 0 rows affected, 1 warning (0.00 sec)
设置远程连接:
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by 'Huixst.9';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> q
Bye
cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld
service mysqld stop
ln -s /data/mysql/bin/mysql /usr/bin/mysql
cd
service mysqld start
chkconfig --add mysqld
chkconfig --list mysqld
chkconfig mysqld on
[root@localhost ~]# mysql -uroot -p'Huixst.9'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> show create database cactiG
*************************** 1. row ***************************
Database: cacti
Create Database: CREATE DATABASE `cacti` /*!40100 DEFAULT CHARACTER SET utf8mb4 */
1 row in set (0.00 sec)
mysql> show create database cactig
+----------+-------------------------------------------------------------------+
| Database | Create Database |
+----------+-------------------------------------------------------------------+
| cacti | CREATE DATABASE `cacti` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+-------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cacti |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> drop database cacti;
Query OK, 0 rows affected (0.00 sec)
mysql> show enginesg
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)
Support 为某种引擎状态
DEFAULT 当前为默认引擎
YES 可以使用
NO 不能使用