linux下安裝mysql-5.7.20


 

一、下載地址html

  https://downloads.mysql.com/archives/community/ mysql

  

 

 

 

 

 

 

 

 

 

 

 

 

二、安裝步驟sql

解壓: 數據庫

groupadd mysql
useradd -r -g mysql -s /bin/false mysql
cd /usr/local
tar zxvf /path/to/mysql-VERSION-OS.tar.gz
mv full-path-to-mysql-VERSION-OS mysql
chown -R mysql mysql/
chgrp -R mysql mysql/
cd mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files

建立配置文件:vim

#先安裝一下這個,要否則初始化有可能會報錯
yum install libaio

 my.cnf配置:socket

#建立配置文件,內容以下,能夠添加你須要的配置:
vim /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M port=3309 datadir=/data/mysql socket=/data/mysql/mysql.sock skip-name-resolve #skip-grant-tables max_connections=1000 character_set_server = utf8 wait_timeout=31536000 interactive_timeout=31536000 collation-server=utf8_general_ci lower_case_table_names=1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/data/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [client] socket=/data/mysql/mysql.sock default-character-set = utf8 [mysql] default-character-set = utf8 [mysql.server] default-character-set = utf8 [mysqld_safe] default-character-set = utf8 #保存內容,按esc輸入以下命令 :wq

 初始化數據庫:ide

mkdir /data/log
chown -R mysql:mysql /data
cd /var/run/
mkdir mysqld
chmod 777 mysqld
cd mysqld
vim mysqld.pid

chmod 777 mysqld.pid
chown mysql:mysql mysqld.pid

/usr/local/mysql/bin/mysqld --initialize --user=mysql

查看初始密碼:spa

cat /data/log/mysqld.log
#執行後關注最後一點:root@localhost: 這裏就是初始密碼

啓動服務,進入mysql,修改初始密碼,運行遠程鏈接(這裏執行完後,密碼將變成:123456)rest

/usr/local/mysql/support-files/mysql.server start

#vim /etc/mysql/my.cnf
#在[mysqld]項下添加
#skip-grant-tables
#service mysqld restart
cd /usr/local/mysql/bin
./mysql -uroot -p
執行後輸入初始密碼
alter user 'root'@'localhost' identified by '123456'; 
flush privileges;
use mysql;

#設置遠程登陸
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;

開機自啓:code

cd /usr/local/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
8、使用service mysqld命令啓動/中止服務
service mysqld start/stop/restart

防火牆開開放3309端口:

vim /etc/sysconfig/iptables
service iptables restart
service mysqld restart

配置全局環境變量:

vi /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
設置環境變量當即生效
# source /etc/profile

查看安裝路徑:

find / -name mysql
相關文章
相關標籤/搜索