MySQL 5.7.222 Binary Installation

Source: Internet
Author: User

MySQL 5.7.22 binary installation
1, go to the official website to download the mysql-5.7.22 binary package

2, create a mysql user:

        useradd mysql -s / sbin / nologin -M
3, extract mysql-5.7.22-el7-x86_64.tar.gz:

        tar xf mysql-5.7.22-el7-x86_64.tar.gz && mv mysql-5.7.22-el7-x86_64.tar.gz / opt / mysql
4,Create related directories:

        cd / opt / mysql mkdir {data, logs, etc} mkidr logs / binlog
5, modify permissions:

        cd / opt / && chown -R mysql.mysql mysql
6, initialize the database:

        cd / opt / mysql
        ./bin/mysqld --initialize --user = mysql --basedir = / opt / mysql --datadir = / opt / mysql / data
        Remember last password
7, modify the my.cnf file:

        echo> /etc/my.cnf vi my.cnf Add to the end of the document
8, configure the mysql service:

        cd / opt / mysql && cp support-files / mysql.server /etc/init.d/mysqld
        Modify permissions chmod + x /etc/init.d/mysqld
        Edit mysqld and add basedir = / opt / mysql datadir = / opt / mysql / data
        chkconfig --add mysqld
9, start the mysql service:

        service mysqld start
        A log error will be reported at this time: Starting MySQL.2018-07-26T14: 24: 53.192088Z mysqld_safe error: log-error set to '/opt/mysql/logs/mysql-error.log', however file don't exists. Create writable for user 'mysql'.
                ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.pid).
        The reason is that the mysql-error.log file under logs cannot be found
        We create one manually
        touch /opt/mysql/logs/mysql-error.log&&chown mysql.mysql mysql-error.log
        Then run service mysqld start
10, configure the environment variables:

        cd && vi .bash_profile Add / opt / mysql / bin after PATH, save and exit
        Execute source .bash_profile
11, log in to the database and change the password:

        After starting the service, execute mysql -uroot -p and enter the password during initialization
        Executing show databases; will report ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
        Run set PASSWORD = PASSWORD (‘123456’); flush privileges to change the password
        After logging out, you can log in again with a new password
At this point, Mysql-5.7.22 binary installation is complete

my.cnf optional content
[mysqld]
# sql_mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES
basedir = / opt / mysql #media directory
datadir = / opt / mysql / data #data directory
port = 3306 #port
pid-file = /opt/mysql/data/mysql.pid #process id
user = mysql #Start user
socket = / opt / mysql / data / mysql.sock #sock file address
bind-address = 0.0.0.0 #bind ip here means bind all ip
server-id = 1 #Used to replicate the environment clock identity instance, this is unique in the replication environment
character-set-server = utf8 #The server's default character set, which is very important, garbled characters will appear in the wrong setting
max_connections = 1000 #Maximum number of concurrent clients allowed
max_connect_errors = 6000 #If the number of errors the client attempts to connect exceeds the value set by this parameter, the server no longer accepts new client connections.
open_files_limit = 65535 #The number of files that the operating system allows the MySQL service to open.
table_open_cache = 128 #Number of tables that all threads can open
max_allowed_packet = 4M #The size of a single packet during network transmission.
back_log = 300
binlog_cache_size = 4M
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
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /opt/mysql/logs/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /opt/mydql/logs/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
# default-storage-engine = MyISAM
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
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
# default-storage-engine = MyISAM
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

[client]
port = 3306
socket = / opt / mysql / data / mysql.sock

[mysql]
no-auto-rehash
# default-character-set = utf8
safe-updates
socket = / opt / mysql / data / mysql.sock

[mysqldump]
quick
max_allowed_packet = 32M

[mysqlhotcopy]
interactive-timeout

[mysql_safe]
open-files-limit = 8192
MySQL 5.7.22 binary installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.