標籤:內容 操作 日誌 files 建議 許可權 round soc char
資料包命名格式解釋
mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz黑色粗體表示為包名稱藍色表示linux系統二進位包紅色表示構架 1、上傳mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz到伺服器,可以使用wget官方下載,或者使用ftp把事先下載好的上傳到伺服器。並安裝依賴包 yum install libaio 2、建立mysql使用者與mysql使用者組,不允許shell登入。 groupadd mysqluseradd mysql -g mysqlusermod mysql -s /bin/nologin 3、解壓mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz到指定目錄/usr/local/mysql/,沒有這個檔案夾請先用mkdir建立這個mysql檔案夾 tar -zxvf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz -C /usr/local/mysql/ 4、將mysql檔案夾所有許可權授權給mysql使用者 [[email protected] mysql]# chown -R mysql:mysql ../mysql 5、建立相關目錄 [[email protected] etc]# cd /data/[[email protected] data]# mkdir mysql[[email protected] data]# chown mysql:mysql mysql/ 6、修改/etc/my.cnf設定檔,一開始系統內建了my.cnf,這個建議mv /etc/my.cnf /etc/my.cnf.back備份,將[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf 拷貝一份到/etc下配置內容 [client]#password = [your_password]#socket = /usr/local/mysql/mysql.sockdefault-character-set= utf8 [mysqld]user = mysqlport = 3306socket = /usr/local/mysql/mysql.sockback_log = 120max_connections = 3000max_connect_errors = 30max_allowed_packet = 32Mbinlog_cache_size = 4Mmax_heap_table_size = 128Msort_buffer_size = 16Mjoin_buffer_size = 16Mquery_cache_size = 128Mquery_cache_limit = 4Mft_min_word_len = 8transaction_isolation = REPEATABLE-READkey_buffer_size = 128Mread_buffer_size = 8Mskip_name_resolve = 1basedir = /usr/local/mysqldatadir = /data/mysqltmpdir = /tmplog_error = error.logdefault-storage-engine = INNODBcharacter-set-server = utf8collation-server = utf8_general_ciserver-id = 1 [mysql]no-auto-rehash 7、初始化資料庫並更改root使用者密碼./bin/mysqld --initialize --datadir=/data/mysql --user=mysql #初始化資料庫的時候,最後一行輸出會有一個root使用者的隨機密碼,記住這個隨機密碼,第一次用root使用者登入是要這個隨機密碼的。在進行其他命令操作之前要修改root使用者的密碼。如果在命令列沒有出現提示資訊,則root隨機密碼在error.log錯誤記錄檔裡面。 命令如下:SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘newpassword‘); 4、開啟mysql服務,我這裡是用mysql使用者啟動。 /usr/local/mysql/support-files/mysql.server start 附錄:1、串連資料庫遇到報錯 [[email protected] bin]# ./mysql -u root -pEnter password:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2) 解決,在/tmp目錄下建立一個軟串連到mysql.sock檔案路徑 [[email protected] tmp]# ln -s /usr/local/mysql/mysql.sock mysql.sock
EHEL安裝mysql二進位包