源码安装mysql 8图解

  1. 云栖社区>
  2. 博客>
  3. 正文

源码安装mysql 8图解

技术佬 2018-09-19 12:25:48 浏览1323
展开阅读全文

1,官网下载

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12.tar.gz

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.12.tar.gz

2,添加mysql用户

useradd mysql -s /sbin/nologin

3,安装基础软件

yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel

1234

4, 解压mysql和解压boost到/usr/local

tar xf mysql-8.0.12.tar.gz
tar zxf mysql-boost-8.0.12.tar.gz -C /usr/local/

5,编译mysql

cd /usr/local/src/mysql-8.0.12
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql-8.0.12/ -DSYSCONFDIR=/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 -DWITH_EMBEDDED_SERVER=1 -DENABLE_DTRACE=0 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8mb4

23456
6,安装mysql

make && make install --大约20分钟

33333333334444
7,配置好my.cnf

[client]

port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4

[mysql]
prompt="MySQL [\d]> "
no-auto-rehash

[mysqld]
port = 3306
socket = /tmp/mysql.sock
default_authentication_plugin = mysql_native_password
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
server-id = 1

init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
collation-server = utf8mb4_0900_ai_ci

skip-name-resolve
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 500M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
binlog_expire_logs_seconds = 604800
log_error = /usr/local/mysql/data/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /usr/local/mysql/data/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
skip-external-locking
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

[mysqldump]
quick
max_allowed_packet = 500M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
8,初始化mysql

cd /usr/local/mysql

mkdir data
chown -R mysql.mysql ./*
chown root.mysql /usr/local/mysql
bin/mysqld --initialize-insecure --user=mysql
77777777777777
9,配置MySQL8

echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

. /etc/profile
cp support-files/mysql.server /etc/init.d/mysql8
chmod +x /etc/init.d/mysql8
sed -i "s@^datadir=.*@datadir=/usr/local/mysql/data@" /etc/init.d/mysql8
sed -i "s@^basedir=.*@basedir=/usr/local/mysql@" /etc/init.d/mysql8
[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# /etc/init.d/mysql8 restart
MySQL server PID file could not be found! [FAILED]
Starting MySQL.

                                     [  OK  ]

99999999999999
10,配置MySQL8 的密码

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# mysql -u root -p
Enter password:

ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
报这个错,意思是少了这个插件
需要mysql8自己的客户端才能连接,所以用全路径连接mysql8
[root@iZwz9hzc7pd8k6u859n9rzZ data]# /usr/local/mysql/bin/mysql -u root -p
666666666666666
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 803
Server version: 8.0.12 Source distribution

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

  1. Other names may be trademarks of their respective
    owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MySQL [(none)]> alter user root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

MySQL [(none)]> alter user root@'127.0.0.1' identified by '123456';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'127.0.0.1'
MySQL [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

MySQL [(none)]>
重新登陆mysql8
88888888888
mysql8源码安装完成。
我的阿里云优惠券地址:https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=3ow2kbko

网友评论

登录后评论
0/500
评论
技术佬
+ 关注