Mysql 编译安装
2017-04-04 15:57
281 查看
Mysql 编译安装
========================================
一:准备
1.1:源码下载
mysql 官网:http://dev.mysql.com/downloads/mysql/
github 地址:https://github.com/mysql/mysql-server
1.2:安装依赖
~]# yum -y install perl perl-devel autoconf cmake gcc gcc-c++ ncurses ncurses-devel
1.3:备注
-DCMAKE_INSTALL_PREFIX= 安装主目录
-DSYSCONFDIR= 配置文件安装位置
-DMYSQL_DATADIR= 数据目录
二:编译安装
2.1:编译初始目录
~]# mkdir -pv /data/mysql/
~]# mkdir /etc/mysql/
~]# useradd -r mysql
~]# rm -rf /etc/my.cnf
~]# rm -rf /etc/my.cnf.d
~]# mkdir -pv /var/{log,run,lib}/mysql/
2.2;编译
~]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/mysql -DMYSQL_DATADIR=/data/mysql/data
~]# make && make install
2.3:配置文件
~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/mysql/my.cnf
~]# vim /etc/mysql/my.cnf
------------------------------------------------------------------------------------------------
[mysqld]
# innodb_buffer_pool_size = 128M
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
# server_id = .....
socket = /tmp/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
skip_name_resolve=on
innodb_file_per_table=on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid
------------------------------------------------------------------------------------------------
2.4:加入系统启动
~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
~]# chkconfig --add mysqld
~]# chkconfig --list mysqld
2.5:初始化
~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
2.6:加入环境变量
~]# echo 'export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin/' > /etc/profile.d/mysql.sh
~]# source /etc/profile.d/mysql.sh
2.7:修改所属用户与组
~]# chown -R mysql:mysql /usr/local/mysql
2.8:启动 停止与重启
~]# service mysqld (start | restart | stop)
2.9:进入mysql客户端
~]# mysql
三:用户授权
3.1:授权(172.0.0.1 localhost 远程 需要分别授权)
grant all privileges on *.* to '用户名'@'允许的主机' identified by '密码' with grant option;
flush privileges;
grant all privileges on *.* to 'mysql'@'127.0.0.1' identified by '123456' with grant option;
grant all privileges on *.* to 'mysql'@'localhost' identified by '123456' with grant option;
grant all privileges on *.* to 'mysql'@'%' identified by '123456' with grant option;
flush privileges;
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
==============================================================
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h iZm5e35fwy8k6ujq6d272yZ password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/mysql/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
========================================
一:准备
1.1:源码下载
mysql 官网:http://dev.mysql.com/downloads/mysql/
github 地址:https://github.com/mysql/mysql-server
1.2:安装依赖
~]# yum -y install perl perl-devel autoconf cmake gcc gcc-c++ ncurses ncurses-devel
1.3:备注
-DCMAKE_INSTALL_PREFIX= 安装主目录
-DSYSCONFDIR= 配置文件安装位置
-DMYSQL_DATADIR= 数据目录
二:编译安装
2.1:编译初始目录
~]# mkdir -pv /data/mysql/
~]# mkdir /etc/mysql/
~]# useradd -r mysql
~]# rm -rf /etc/my.cnf
~]# rm -rf /etc/my.cnf.d
~]# mkdir -pv /var/{log,run,lib}/mysql/
2.2;编译
~]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/mysql -DMYSQL_DATADIR=/data/mysql/data
~]# make && make install
2.3:配置文件
~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/mysql/my.cnf
~]# vim /etc/mysql/my.cnf
------------------------------------------------------------------------------------------------
[mysqld]
# innodb_buffer_pool_size = 128M
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
# server_id = .....
socket = /tmp/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
skip_name_resolve=on
innodb_file_per_table=on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid
------------------------------------------------------------------------------------------------
2.4:加入系统启动
~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
~]# chkconfig --add mysqld
~]# chkconfig --list mysqld
2.5:初始化
~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
2.6:加入环境变量
~]# echo 'export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin/' > /etc/profile.d/mysql.sh
~]# source /etc/profile.d/mysql.sh
2.7:修改所属用户与组
~]# chown -R mysql:mysql /usr/local/mysql
2.8:启动 停止与重启
~]# service mysqld (start | restart | stop)
2.9:进入mysql客户端
~]# mysql
三:用户授权
3.1:授权(172.0.0.1 localhost 远程 需要分别授权)
grant all privileges on *.* to '用户名'@'允许的主机' identified by '密码' with grant option;
flush privileges;
grant all privileges on *.* to 'mysql'@'127.0.0.1' identified by '123456' with grant option;
grant all privileges on *.* to 'mysql'@'localhost' identified by '123456' with grant option;
grant all privileges on *.* to 'mysql'@'%' identified by '123456' with grant option;
flush privileges;
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
==============================================================
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h iZm5e35fwy8k6ujq6d272yZ password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/mysql/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
相关文章推荐
- MySQL 5.5 三大安装方式:【二进制、源代码编译 和 RPM 包】 安装步骤及优缺点比较
- Linux源码安装mysql 5.5.13 (cmake编译)
- 在CentOS 7下编译安装Nginx+PHP+MySQL环境
- Nginx 1.5.2 + PHP 5.5.1 + MySQL 5.6.10 在 CentOS 下的编译安装
- mysql5.5版本编译安装操做笔记
- CentOS 6.4下编译安装MySQL 5.6.14
- CentOS 7 编译安装 MySQL-5.7.9
- MySQL编译安装(多实例)
- httpd 2.4.9 + mysql-5.5.33 + php-5.4.26编译安装过程
- linux下编译安装mysql
- Redhat EL 5.3上安装Cacti(1)- 编译安装Apache、MySQL
- 源码编译安装 MySQL 5.5.x 实践
- mysql-安装之CAMKE编译安装
- Linux(CentOS6.5)下编译安装MySQL Community Server 5.7.12
- Linux(centos) 编译安装 Mysql 后配置开机自动启动
- CentOS 6.4 64Bit 编译安装Mysql 5.6.11源码包
- 基于模块化编译安装LAMP:httpd 2.4.9 + mysql-5.5.33 + php-5.4.26编译安装
- MySQL-5.5 cmake编译安装
- mysql编译安装优化