Ubuntu14.04.*源码安装MySQL数据库mysql-5.6.*.tar.gz

时间:2021-09-26 21:02:24

1:依赖软件下载:

ftp://ftp.gnu.org/gnu/m4/
http://ftp.gnu.org/gnu/bison/
https://cmake.org/download/
ftp://invisible-island.net/ncurses/
http://ftp.kaist.ac.kr/mysql/Downloads/
2:此笔记使用版本:

m4-1.4.17.tar.gz
bison-3.0.tar.gz
ncurses-6.0.tar.gz
cmake-3.3.2.tar.gz
mysql-5.6.33.tar.gz
3:安装依赖:

m4:

	tar zxvf m4-1.4.17.tar.gz 
cd m4-1.4.17
./configure
make && make install
man m4
bison:

	tar zxvf bison-3.0.tar.gz
cd bison-3.0
./configure
make && make install
man bison
ncurses:

	tar zxvf ncurses-6.0.tar.gz
cd ncurses-6.0
./configure
make && make install
man ncurses
cmake:

	tar zxvf cmake-3.3.2.tar.gz
cd cmake-3.3.2
./bootstrap
make && make install
cmake --version

3:源码安装mysql数据库:

①:安装目录和数据目录:

mkdir -p /usr/local/mysql
mkdir /data
②:用户和组:

grep mysql /etc/group
grep mysql /etc/passwd

groupadd mysql
useradd mysql -g mysql -d /usr/local/mysql -s /bin/sh
③:cmake编译工具编译mysql源代码:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_bin -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1
注: 详细参数参考
④:编译和安装
make && make install
注:建议磁盘大小:30G以上,安装编译安装前可以:make test   :检查安装最佳。

⑤:进入安装目录下,初始化MySQL数据库:

cd /usr/local/mysql
./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data --user=mysql
⑥:配置mysql配置文件:

cp -R my.cnf /etc/
注:简单配置如下:

[client]
port = 3306
socket = /data/mysql.sock
[mysqld]
basedir = /usr/local/mysql
datadir = /data
port = 3306
socket = /data/mysql.sock
log-error = /data/mysql-error.log
pid-file = /data/mysql.pid
user = mysql
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
⑦:目录文件都属于mysql用户:

chown -R mysql.mysql /usr/local/mysql/
chown -R mysql.mysql /data
chown -R mysql.mysql /etc/my.cnf
⑧:启动mysql数据库:

cd support-files/
./mysql.server start
cp -R mysql.server /etc/init.d/mysqld
chown -R mysql.mysql mysqld
service mysqld start
⑨:使用mysql客户端命令-配置mysql 环境变量

vim /etc/profile
#mysqlexport MYSQL_HOME=/usr/local/mysqlexport PATH=$MYSQL_HOME/bin:$PATH
source /etc/profile
此时可以直接在命令行输入:mysql ,启动客户端。

⑩:设置mysql登录名和密码和权限:

root@root:/usr/local/mysql# mysql
mysql>grant all on *.* to usernamexxx@'10.188.1.%' Identified by 'ipasswordxx123';