mysql 5.7.19 二進位最新安裝

來源:互聯網
上載者:User

標籤:mysql 5.7.19最新版二進位安裝

##############################

2017-08-08  筆記

一、最佳化部分

1.作業系統參數調優

2.資料庫參數調優

3.防火牆設定等

#############################

二、安裝部分

1.建立使用者和組

# groupadd mysql

# useradd -g mysql mysql


2.建立資料庫安裝目錄、授權

# mkdir /mysql /mysql/data /mysql/log 

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


3.到安裝目錄,解壓安裝檔案

#cd /usr/local

# tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

# mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql


4.授權

# chown -R mysql.mysql mysql


5.驗證許可權

# ls -l mysql

total 52

drwxr-xr-x  2 mysql mysql  4096 Aug  8 04:06 bin

-rw-r--r--  1 mysql mysql 17987 Jun 22 22:13 COPYING

drwxr-xr-x  2 mysql mysql  4096 Aug  8 04:06 docs

drwxr-xr-x  3 mysql mysql  4096 Aug  8 04:06 include

drwxr-xr-x  5 mysql mysql  4096 Aug  8 04:06 lib

drwxr-xr-x  4 mysql mysql  4096 Aug  8 04:06 man

-rw-r--r--  1 mysql mysql  2478 Jun 22 22:13 README

drwxr-xr-x 28 mysql mysql  4096 Aug  8 04:06 share

drwxr-xr-x  2 mysql mysql  4096 Aug  8 04:06 support-files


6.編輯參數檔案

vim /etc/my.cnf


[client]

port = 3306

socket = /tmp/mysql.sock


[mysqld]

server_id=10

port = 3306

user = mysql

character-set-server = utf8mb4

default_storage_engine = innodb

log_timestamps = SYSTEM

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

innodb_undo_tablespaces=3

#####====================================[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=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES



7.安裝資料庫

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


8.配置開機檔案

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

chkconfig --add mysql

chkconfig mysql on

service mysql start


9.配置環境變數


vi /etc/profile

#for mysql  

mysql_home=/usr/local/mysql

PATH=$PATH:$mysql_home/bin

source /etc/profile


10.查看預設密碼

grep -i password /mysql/log/mysql-error.log 


11.初始化密碼

mysql -uroot -p‘xxxxx‘

SET PASSWORD=PASSWORD(‘root‘);

flush privileges;


12.資料庫常規啟停

# mysqladmin -uroot -proot shutdown

#mysqld_safe --defaults-file=/etc/my.cnf &

#ps -ef|grep mysql



13.安全配置

# mysql_secure_installation 

Securing the MySQL server deployment.


Enter password for user root: 


VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin?


Press y|Y for Yes, any other key for No: y


There are three levels of password validation policy:


LOW    Length >= 8

MEDIUM Length >= 8, numeric, mixed case, and special characters

STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file


Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2

Using existing password for root.


Estimated strength of the password: 25 

Change the password for root ? ((Press y|Y for Yes, any other key for No) : y


New password: 


Re-enter new password: 

Sorry, passwords do not match.


New password: 


Re-enter new password: 

Sorry, passwords do not match.


New password: 


Re-enter new password: 


Estimated strength of the password: 50 

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

 ... Failed! Error: Your password does not satisfy the current policy requirements


New password: 


Re-enter new password: 


Estimated strength of the password: 100 

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.


Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Success.



Normally, root should only be allowed to connect from

‘localhost‘. This ensures that someone cannot guess at

the root password from the network.


Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

Success.


By default, MySQL comes with a database named ‘test‘ that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.



Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

 - Dropping test database...

Success.


 - Removing privileges on test database...

Success.


Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.


Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Success.


All done! 


本文出自 “roidba” 部落格,請務必保留此出處http://roidba.blog.51cto.com/12318731/1954372

mysql 5.7.19 二進位最新安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.