MYSQL 源码安装

1.官网下载源码安装包(5.5以后版本是通过cmake编译安装)
yum install cmake
2.创建安装目录和数据目录
mkdir -p /opt/mysql
mkdir -p /opt/mysqldata
3.创建用户以及组,设置环境变量
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /opt/mysqldata
环境变量:
export PATH
export LANG=en_US.utf8
export MYSQL_HOME=/opt/mysql
export MYSQL_DATA=/opt/mysqldata
export PATH= MYSQLHOME/bin: PATH:.
4.编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/opt/mysqldata -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=1
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录
-DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录
-DDEFAULT_CHARSET=utf8     //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校验字符
-DEXTRA_CHARSETS=all     //安装所有扩展字符集
-DENABLED_LOCAL_INFILE=1    //允许从本地导入数据
5.创建系统数据库相关表
cd /opt/mysql
scripts/mysql_install_db –user=mysql
6.手动启动mysql
cd /opt/mysql
./bin/mysqld_safe –user=mysql &
7.添加服务
cd /opt/mysql
cp support-files/mysql.server /etc/init.d/mysql
添加后,可以通过service mysql stop|start|restart|status
8.连接数据库
mysql -h 127.0.0.1 -uroot

创建删除数据库:
create | drop database dbname;
选择数据库查看表:
use dbname;
show tables;
帮助使用:
mysql> ? contents
You asked for help about help category: “Contents”
For more information, type ‘help ’, where is one of the following
categories:
Account Management
Administration
Compound Statements
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Procedures
Storage Engines
Table Maintenance
Transactions
User-Defined Functions
Utility
查看支持的数据类型:
? data types
For more information, type ‘help ’, where is one of the following
topics:
AUTO_INCREMENT
BIGINT
BINARY
BIT
BLOB
BLOB DATA TYPE
BOOLEAN
CHAR
CHAR BYTE
DATE
DATETIME
DEC
DECIMAL
DOUBLE
DOUBLE PRECISION
ENUM
FLOAT
INT
INTEGER
LONGBLOB
LONGTEXT
MEDIUMBLOB
MEDIUMINT
MEDIUMTEXT
SET DATA TYPE
SMALLINT
TEXT
TIME
TIMESTAMP
TINYBLOB
TINYINT
TINYTEXT
VARBINARY
VARCHAR
YEAR DATA TYPE
查看建表语句
show create table xxxx \G;
配置文件
MYSQL 源码安装_第1张图片
上表表示优先级从上到下,优先使用/etc/my.cnf文件

你可能感兴趣的:(mysql)