安裝編譯需要的依賴
yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel
rpm -qa |grep libaio
yum install libaio libaio-devel
wget
建立使用者和組
groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql
建立安裝目錄和資料存放目錄
mkdir -p /usr/local/mysql
mkdir -p /data/mysql
修改許可權
chown -r mysql.mysql /usr/local/mysql
chown -r mysql.mysql /data/mysql
chmod -r 755 /usr/local/mysql/
chmod -r 755 /data/mysql/
解壓
tar -zxf mysql-boost-8.0.12.tar.gz
mkdir /usr/local/boost
wget
tar -xvzf boost_1_59_0.tar.gz
配置
cmake . -dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/mnt/mnt2/mysql \
-dsysconfdir=/etc \
-dmysql_tcp_port=3306 \
-dwith_boost=/usr/local/boost \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci \
-denabled_local_infile=on \
-dwith_innodb_memcached=on \
-dwith_innobase_storage_engine=1 \
-dwith_federated_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwithout_example_storage_engine=1 \
-dwith_perfschema_storage_engine=1
引數說明
cmake_install_prefix :指定基礎安裝目錄編譯安裝mysql_datadir :指定資料目錄
sysconfdir=/etc :指定配置檔案掃瞄目錄
mysql_tcp_port :指定埠號
with_boost :指定boost所在目錄
default_charset :指定預設字符集
default_collation :指定預設排序規則
enabled_local_infile=on :是否為load data infile啟用local
with_innodb_memcached=on :是否生成memcached共享庫
make && make install
初始化資料庫
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
建立配置檔案
vi /etc/my.cnf
[client]配置環境變數port=3306
socket=/tmp/mysql.sock
default-character-set=utf8
#user=root
#password=123
#資料庫大小寫不敏感
lower_case_table_names = 1
[mysqld]
server-id=1
#skip-grant-tables
port=3306
user=mysql
max_connections=200
socket=/tmp/mysql.sock
basedir=/usr/local/mysql
datadir=/data/mysql
pid-file=/data/mysql/mysql.pid
init-connect=『set names utf8』
character-set-server=utf8
default-storage-engine=innodb
log_error=/data/mysql/mysql-error.log
slow_query_log_file=/data/mysql/mysql-slow.log
[mysqldump]
quick
max_allowed_packet=16m
echo "path=/usr/local/mysql/bin:$path" >> /etc/profile
source /etc/profile
做成系統服務
vi /etc/systemd/system/mysqld.service
[unit]啟動mysqldescription=mysql server daemon
documentation=man:mysql(8)
documentation=
after=network.target
after=syslog.target
[install]
wantedby=multi-user.target
[service]
user=mysql
group=mysql
type=notify
timeoutsec=0
permissionsstartonly=true
execstart=/usr/local/mysql/bin/mysqld $mysqld_opts
limitnofile = 10000
restart=always
restartpreventexitstatus=1
environment=mysqld_parent_pid=1
privatetmp=false
systemctl start mysqld.service
#修改root密碼:使用with指定認證方式
mysql -uroot
alter user 『root』@『localhost』 identified with mysql_native_password by 『你的密碼』;alter user 『root』@『localhost』 identified with caching_sha2_password by 『你的密碼』;
centos 7安裝mysql 8教程
mysql日誌目錄 var log mysqld.log 啟動命令 systemctl start mysqld.service 注意 mysql 8 預設設定是區分表名大小寫的。在初始化的時候設定 lower case table names 1才有效!在初始化的時候設定 lower case t...
阿里雲Centos7安裝mysql8
centos7,mysql 8.0.15 1.el7.x86 64.rpm bundle.tar,xshell 6,xftp 6 mysqld initialize 若報這個異常error while loading shared libraries libaio.so.1 cannot open ...
centos7安裝mysql8完美教程
centos7安裝mysql8完美教程 配置mysql 1.剛剛啟動成功之後,用命令檢視預設密碼並且登入 檢視 cat var log mysqld.log grep password 登陸 mysql u root p 然後輸入密碼 2.修改密碼 set global validate passw...