標籤:err client packet code commit nod bsp add table
上傳檔案並解壓
[[email protected] ~]# cd /usr/local/[[email protected] local]# ls mysql*mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz[[email protected] local]# tar zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
解壓完畢之後建立軟串連
[[email protected] local]# ln -s mysql-5.7.9-linux-glibc2.5-x86_64 mysql[[email protected] local]# cd mysql[[email protected] mysql]# lltotal 160drwxr-xr-x 2 7161 wheel 4096 Oct 12 2015 bin-rw-r--r-- 1 7161 wheel 17987 Oct 12 2015 COPYINGdrwxr-xr-x 2 7161 wheel 4096 Oct 12 2015 docsdrwxr-xr-x 3 7161 wheel 4096 Oct 12 2015 include-rw-r--r-- 1 7161 wheel 108028 Oct 12 2015 INSTALL-BINARYdrwxr-xr-x 5 7161 wheel 4096 Oct 12 2015 libdrwxr-xr-x 4 7161 wheel 4096 Oct 12 2015 man-rw-r--r-- 1 7161 wheel 2478 Oct 12 2015 READMEdrwxr-xr-x 28 7161 wheel 4096 Oct 12 2015 sharedrwxr-xr-x 2 7161 wheel 4096 Oct 12 2015 support-files
建立使用者及組
[[email protected] mysql]# groupadd mysql[[email protected] mysql]# useradd -r -g mysql mysql
為mysql路徑下面的檔案進行使用者和組的修改
[[email protected] mysql]# chown -R mysql .[[email protected] mysql]# chgrp -R mysql .
建立資料檔案和記錄檔路徑
[[email protected] local]# mkdir /mydata /mydata/data /mydata/log[[email protected] mysql]# chown -R mysql:mysql /mydata
建立my.cnf檔案
[[email protected] mysql]# vi /etc/my.cnf[client]port = 3306socket = /var/lib/mysql/mysql.sock[mysqld]server_id=10port = 3306user = mysqlcharacter-set-server = utf8mb4default_storage_engine = innodblog_timestamps = SYSTEMsocket = /var/lib/mysql/mysql.sockbasedir = /usr/local/mysqldatadir = /mydata/datapid-file = /mydata/data/mysql.pidmax_connections = 1000max_connect_errors = 1000table_open_cache = 1024max_allowed_packet = 128Mopen_files_limit = 65535#####====================================[innodb]==============================innodb_buffer_pool_size = 1024Minnodb_file_per_table = 1innodb_write_io_threads = 4innodb_read_io_threads = 4innodb_purge_threads = 2innodb_flush_log_at_trx_commit = 1innodb_log_file_size = 512Minnodb_log_files_in_group = 2innodb_log_buffer_size = 16Minnodb_max_dirty_pages_pct = 80innodb_lock_wait_timeout = 30innodb_data_file_path=ibdata1:1024M:autoextend#####====================================[log]==============================log_error = /mydata/log/mysql-error.log slow_query_log = 1long_query_time = 1 slow_query_log_file = /mydata/log/mysql-slow.logsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
初始化資料庫
在5.7.6之前初始化的方法是:bin/mysql_install_db --user=mysql
5.7.6之後的版本初始化資料庫不再使用mysql_install_db
[[email protected] mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp
[[email protected] mysql]# bin/mysql_ssl_rsa_setup --datadir=/mydata/data
如果配置了my.cnf的log_error,那麼初始密碼在log_error檔案中,否則會列印出來。
初始完畢之後更改/usr/local/mysql路徑下面檔案的所屬使用者
[[email protected] mysql]# chown -R root .
配置開機檔案
cp support-files/mysql.server /etc/init.d/mysqlchkconfig --add mysqlchkconfig mysql onservice mysql start
配置環境變數
[[email protected] ~]# vi /etc/profilemysql_home=/usr/local/mysqlPATH=$PATH:$mysql_home/binsource /etc/profile
修改密碼
在5.7中儲存密碼的欄位不再是password了,變成了authentication_string
update mysql.user set authentication_string=password(‘root‘) where user=‘root‘;
修改root密碼後如果第一次使用root使用者登入mysql系統還會需要重設一次root密碼
SET PASSWORD=PASSWORD(‘root‘);
flush privileges;
mysql二進位安裝