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());