Binary installation mysql8.0

Installation dependencies 
yum install -y libaio
yum install -y perl perl-devel
 
 
 
Decompression
 
mkdir /opt/mysql
mv mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz /opt/mysql/
 
cd /opt/mysql
tar xvJf mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz
 
 
 
Creating a link
cd /usr/local
ln -s /opt/mysql/mysql-8.0.16-linux-glibc2.12-x86_64 mysql
 
 
 
Create a user running
groupadd mysql
useradd -g mysql -d /usr/local/mysql -s /sbin/nologin -M -n mysql
 
 
 
Creating the required directory
mkdir -p /data/{mysql,tmp}/
mkdir / var / lib / mysql
 
 
Modify permissions
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql:mysql /data/{mysql,tmp}/
chown mysql:mysql /var/lib/mysql
 
 
 
 
Profile content
#my.cnf
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
 
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
tmpdir=/data/tmp
user=mysql
port=3306
server-id=62
character-set-server=utf8
binlog_format = ROW
transaction_isolation = READ-COMMITTED # transaction commits rating
old_passwords = 0 # close the old password option
secure-auth = 1 # prevent low version of Client Access
sql-mode = "NO_AUTO_CREATE_USER" # prohibits create a user does not add password
safe-user-create = 1 # Only users who have INSERT privileges on the database table to use mysql.user GRANT command
symbolic-links = 0 # supports hyperlinks file
skip_name_resolve = 1 # Disable DNS host name lookup
lower_case_table_names = 1 # case insensitive
local_infile = 0 # prohibited load data
log_bin
log_slave_updates
innodb_open_files = 1000
 
innodb_adaptive_hash_index = ON # adaptive open auxiliary hash index
innodb_file_per_table #innodb file a separate table
innodb_file_format = Barracuda # Enable compression
innodb_buffer_pool_size = buff pool size of 300MB #innodb
innodb_flush_method = O_DIRECT # avoid double buffering (double buffering) and reducing the pressure of the swap
innodb_buffer_pool_dump_at_shutdown=1 #shutdown时dump出buff pool内容
load the contents buff pool innodb_buffer_pool_load_at_startup = 1 #shutdown
sync_binlog = 1
innodb_flush_log_at_trx_commit = 1
After insertion delayed_insert_limit = 100 # 100 select line allows to run
delayed_insert_timeout = 300 #INSERT statement execution timeout
delayed_queue_size = 1000 # delay queue length
sort_buffer_size = 2M # sort of memory for each thread
join_buffer_size = 4M # memory for each thread join
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/slow.log
max_connections = 1000 # maximum number of connections
max_connect_errors = 1000 # maximum number of connections error
max_allowed_packet = 1G # packet size
max_connections = 1000
lock_wait_timeout = 3600
table_definition_cache = definition information storing table 512 #
table_open_cache = 200 # deposit currently open table handle
tmp_table_size = 16777216 # temporary table size
wait_timeout = 2880000 # Wait Timeout
interactive_timeout = 2880000
 
[mysql]
default-character-set=utf8
 
 
 
Permissions modify my.cnf
chown mysql:mysql /etc/my.cnf 
 
 
 
Add to the environment variables
echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile 
source /etc/profile
 
 
MySQL initialization
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql --initialize-insecure
 
 
Creating error.log (8.0 version does not automatically create without error.log circumstances, will complain)
 
HOST_NAME=`hostname`
touch /data/mysql/$HOST_NAME.err
chown mysql.mysql /data/mysql/$HOST_NAME.err
 
 
Start MySQL
cp /opt/mysql/mysql-8.0.16-linux-glibc2.12-x86_64/support-files/mysql.server /etc/init.d/mysqld
 
/etc/init.d/mysqld start 
 
 
 
change Password
 
mysql> ALTER USER 'root' @ 'localhost' IDENTIFIED BY "chengce243"; (new default encryption)
 
Note 8.0 defaults to the new encryption: caching_sha2_password, will lead to the following version 8.0 client can not connect:
 
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /data/mysql/lib/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
 
Solution: Modify the old encryption method: mysql_native_password
 
mysql> ALTER USER `root` @`% `IDENTIFIED WITH mysql_native_password BY" chengce243 "; # modify the encryption rule 
 
mysql> ALTER USER `root` @`% `IDENTIFIED BY" chengce243 "PASSWORD EXPIRE NEVER; # never expires
 
mysql> FLUSH PRIVILEGES; # refresh permission 
 
My.cnf or modify the parameters using the old encryption method in the configuration file
 
default_authentication_plugin = mysql_native_password
 

Guess you like

Origin www.cnblogs.com/liang545621/p/12606263.html