mysql应用编译安装:
# wget -c https://downloads.mysql.com/archives/get/file/mysql-5.6.25.tar.gz
# apt-get -y install make gcc g++ cmake perl vim
# apt-get install make gcc g++ libcurl3-openssl-dev libfreetype6-dev libmcrypt-dev
# apt-get install libpcre3 libpcre3-dev zlib1g-dev libssl-dev build-essential
# apt-get install openssl libssl-dev
# groupadd -r mysql
# useradd -g mysql -r -d /mydata/data mysql
# mkdir /mydata/data -pv
# tar xf mysql-5.6.25.tar.gz
# cd mysql-5.6.25
# vim cmd-line-utils/libedit/terminal.c
把terminal_set方法中的 char buf[TC_BUFSIZE]; 这一行注释,再把 area = buf;改为 area = NULL;
protected int
terminal_set(EditLine *el, const char *term)
{
int i;
/*char buf[TC_BUFSIZE];*/
char *area;
...
area = NULL;
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mydata/data \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
# make
# make install
# cd /usr/local/mysql
# sudo chown -R mysql:mysql ./
# sudo chown -R mysql:mysql /mydata/data
# cp support-files/my-default.cnf /etc/my.cnf
# sudo chown mysql:mysql /etc/my.cnf
# sudo vi /etc/my.cnf
[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
# cd /usr/local/mysql
# sudo scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data/
# 方法1:
# 直接启动
# bin/mysqld_safe &
# 检查MySQL服务是否启动:
# ps -ef |grep mysql
# 方法2:
# 通过服务启动
# 添加服务,复制启动脚本到/etc/init.d目录:
# cd /usr/local/mysql/
# cp support-files/mysql.server /etc/init.d/mysql
# 设置文本的权限:
# sudo chmod 755 /etc/init.d/mysql
# 启动:
# sudo /etc/init.d/mysql start
# (关闭mysql服务:sudo /etc/init.d/mysql stop)
# 或者
# sudo service mysql start
# (关闭mysql服务:sudo service mysql stop)
# 检查MySQL服务是否启动:
# ps -ef |grep mysql
# 为了直接调用mysql,需要将mysql的bin目录加入PATH环境变量。
# 编辑/etc/profile.d/:
# sudo vim /etc/profile.d/mysql
PATH=$PATH:/usr/local/mysql/bin
export PATH
# 关闭文件,运行下面的命令,让配置立即生效:
# source /etc/profile
# mysql -h127.0.0.1 -uroot -p
# update mysql.user set password=password('root') where user='root';
# flush privileges;
# service mysql restart
# update-rc.d nginx defaults 99
# mysql> select now(),user(),version();
+---------------------+------------------+-----------+
| now() | user() | version() |
+---------------------+------------------+-----------+
| 2018-08-27 19:00:59 | evescn@localhost | 5.6.25 |
+---------------------+------------------+-----------+
# CREATE DATABASE IF NOT EXISTS evescn DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
# CREATE TABLE IF NOT EXISTS `runoob_tbl`(
`runoob_id` INT UNSIGNED AUTO_INCREMENT,
`runoob_title` VARCHAR(100) NOT NULL,
`runoob_author` VARCHAR(40) NOT NULL,
`submission_date` DATE,
PRIMARY KEY ( `runoob_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
# INSERT INTO runoob_tbl
(runoob_title, runoob_author, submission_date)
VALUES
("学习 MySQL", "菜鸟教程", NOW());
# INSERT INTO runoob_tbl
(runoob_title, runoob_author, submission_date)
VALUES
("学习 PHP", "菜鸟教程", NOW());