mysql5.7.27在ubuntu16.04安装

依赖包安装

sudo apt install make cmake gcc g++ perl bison libaio-dev libncurses5 libncurses5-dev libnuma-dev

配置相关

sudo groupadd mysql
sudo useradd -r -g mysql -s /sbin/nologin mysql
sudo mkdir -p /home/mysql/mysql
sudo mkdir -p /home/mysql/data
sudo mkdir -p /home/mysql/log
cd /home
sudo chown -R mysql.mysql mysql/

下载源码

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.27.tar.gz
tar -zxvf mysql-boost-5.7.27.tar.gz
cd mysql-5.7.27

cmake . -DCMAKE_INSTALL_PREFIX=/home/mysql/mysql -DMYSQL_DATADIR=/home/mysql/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/ubuntu/dumpserver/mysql/mysql-5.7.27/boost -DSYCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1   -DENABLED_LOAL_INFILE=1  -DENABLE_DRACE=0  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EMBEDDED_SERVER=1 
sudo make
sudo make install

初始化并启动mysql

cd /home/mysql/mysql
sudo bin/mysqld --initialize-insecure --user=mysql --basedir=/home/mysql/mysql --datadir=/home/mysql/data

mkdir etc
cd etc
vi my.cnf
[client]
port=3306  
socket=/home/mysql/data/mysql.sock  
default-character-set=utf8  
[mysqld]  
port=3306  
user=mysql  
socket=/home/mysql/data/mysql.sock  
pid-file=/home/mysql/data/mysql.pid  
basedir=/home/mysql/mysql
datadir=/home/mysql/data
tmpdir=/home/mysql/tmpdir  
character-set-server=utf8
log_error=/home/mysql/log/mysql.err  
server_id=2  
log_bin=/home/mysql/log/binlog  
general_log_file=/home/mysql/log/general_log  
general_log=1  
slow_query_log=ON  
long_query_time=1
slow_query_log_file=/home/mysql/log/query_log  
log_queries_not_using_indexes=ON

管理数据库

sudo -i
bin/mysql -uroot

添加mysql用户

grant create,select,insert,update on *.*  to 'dump1'@'%'  identified by  "dump1";

flush privileges;

测试子账户

bin/mysql -udump1 -p

你可能感兴趣的:(mysql5.7.27在ubuntu16.04安装)