第一次在自己虛機(jī)上安裝mysql 中間碰到很多問題 在這里記下來,分享一下。
linux centOS 6
mysql版本 mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
1、groupadd mysql ## 添加一個(gè)mysql組
2、useradd -r -g mysql mysql ## 添加一個(gè)用戶
3、解壓縮下載的包,tar -xzvf /usr/local/mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
4、mv /usr/local/mysql-5.7.13-linux-glibc2.5-x86_64 /usr/local/mysql ##重命名
解壓后目錄:

5、mkdir /usr/local/mysql/data ## 默認(rèn)是沒有這個(gè)文件夾得 用來放數(shù)據(jù)
6、chown -R mysql:mysql ./ ##進(jìn)入mysql包中, 給這個(gè)包授權(quán) 給mysql
7、chgrp -R mysql:mysql ./ ##進(jìn)入mysql包中
8、bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data ##進(jìn)入mysql文件名 basedir 為mysql 的路徑, datadir 為mysql的 data 包,里面 存放著mysql自己的包, 如user
網(wǎng)上很多教程mysql_install_db 方式安裝的,我剛開始也是這么安裝,各種報(bào)錯(cuò)、失敗,mysql_install_db 命令不推薦、按上面的命令來就好

此處需要注意記錄生成的臨時(shí)密碼,如上文:YLi>7ecpe;YP
9、bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
10、進(jìn)入mysql support-file
11、cp my-default.cnf /etc/my.cnf
發(fā)現(xiàn)這個(gè)版本就沒有my-default

這個(gè)是時(shí)候我們自己創(chuàng)建一個(gè)(內(nèi)部代碼如圖): 重點(diǎn)下面兩個(gè)socket(紅色)對(duì)應(yīng)的值必須一致,不然啟動(dòng)以后鏈接不上
#dvice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # 一般配置選項(xiàng) basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 #socket = /temp/mysqld.sock socket = /var/run/mysqld/mysqld.sock character-set-server=utf8 #下面是可選項(xiàng),要不要都行,如果出現(xiàn)啟動(dòng)錯(cuò)誤,則全部注釋掉,保留最基本的配置選項(xiàng),然后嘗試添加某些配置項(xiàng)后啟動(dòng),檢測(cè)配置項(xiàng)是否有誤 back_log = 300 max_connections = 3000 max_connect_errors = 50 table_open_cache = 4096 max_allowed_packet = 32M #binlog_cache_size = 4M max_heap_table_size = 128M read_rnd_buffer_size = 16M sort_buffer_size = 16M join_buffer_size = 16M thread_cache_size = 16 query_cache_size = 128M query_cache_limit = 4M ft_min_word_len = 8 thread_stack = 512K transaction_isolation = REPEATABLE-READ tmp_table_size = 128M #log-bin=mysql-bin long_query_time = 6 server_id=1 innodb_buffer_pool_size = 1G innodb_thread_concurrency = 16 innodb_log_buffer_size = 16M innodb_log_file_size = 512M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 innodb_file_per_table = on [mysqldump] quick max_allowed_packet = 32M [mysql] no-auto-rehash socket = /var/run/mysqld/mysqld.sock default-character-set=utf8 safe-updates [myisamchk] key_buffer = 16M sort_buffer_size = 16M read_buffer = 8M write_buffer = 8M [mysqlhotcopy] interactive-timeout [mysqld_safe] open-files-limit = 8192 [client] loose-default-character-set = utf8
新聞熱點(diǎn)
疑難解答
圖片精選