MySql5.7 free installation configuration process (ubuntu16.04)

First, the installation environment:

  Operating System: ubuntu16.04

  Database: mysql-5.7.17-linux-glibc2.5-x86_64 (free installation)

Second, unzip

  tar -xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

  mv mysql-5.7.17-linux-glibc2.5-x86_64   /usr/local/mysql

Third, add users and groups

  groupadd mysql;

  useradd -g mysql mysql;

Fourth, create directories and directory permissions:

  mkdir /mysql /mysql/data /mysql/log

  Modify directory permissions

   chown -R mysql:mysql /usr/local/mysql /mysql
Fifth, create a file in the / etc directory: my.cnf

  Creating direct use vi my.cnf

[client]
port = 3306
socket = /tmp/mysql.sock

[mysqld]
server_id=10
port = 3306
user = mysql
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /mysql/data
pid-file = /mysql/data/mysql.pid
max_connections = 1000
max_connect_errors = 1000
table_open_cache = 1024
max_allowed_packet = 128M
open_files_limit = 65535
#####====================================[innodb]==============================
innodb_buffer_pool_size = 1024M
innodb_file_per_table = 1
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_purge_threads = 2
innodb_flush_log_at_trx_commit = 1
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 30
innodb_data_file_path=ibdata1:1024M:autoextend

#####====================================[log]==============================
log_error = /mysql/log/mysql-error.log 
slow_query_log = 1
long_query_time = 1 
slow_query_log_file = /mysql/log/mysql-slow.log

sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Sixth, to initialize the database and configuration

  Note: version 5.7.6 is no longer initialize the database after using mysql_install_db

  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data  --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp

 If log_error my.cnf configuration, the initial password log_error file, otherwise it will be printed.

  bin/mysql_ssl_rsa_setup --datadir=/mysql/data

  Modify directory permissions

 chown -R mysql:mysql /usr/local/mysql /mysql

  Configure the startup file

 cp support-files/mysql.server /etc/init.d/mysql

  Configuration environment variable

  mysql_home=/usr/local/mysql
  PATH=$PATH:$mysql_home/bin

Seven, the configuration database and remote access password:

  Use initialization password to log in:

  The password is stored in a log file: sudo vi mysql-error.log

  mysql -u root -p *******

 Initial use, set the root password:
   SET PASSWORD=PASSWORD('root');
  Before you can use and modify the operation of the database:

   update mysql.user set authentication_string=password('root') where user='root';

  Modify Remote Access

       . mysql> * * the GRANT the TO ALL PRIVILEGES the ON 'the root' @ '%' the IDENTIFIED BY 'the root_password' the WITH the GRANT the OPTION;
       mysql> the FLUSH PRIVILEGES;
VIII mysql to increase the system default boot ubuntu

  sudo update-rc.d mysql defaults

发布了36 篇原创文章 · 获赞 9 · 访问量 11万+

Guess you like

Origin blog.csdn.net/gudufeiyang/article/details/54911665