您好,登錄后才能下訂單哦!
這篇文章主要介紹了MySQL 5.7.21如何在Linux平臺中安裝Part 2,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
目錄名稱 | 參數名稱 | 路徑地址 |
---|---|---|
安裝目錄 | basedir | /usr/local/mysql |
數據文件目錄 | datadir | /data/mysql/data |
臨時文件目錄 | tmpdir | /data/mysql/tmp |
socket文件目錄 | socket | /data/mysql/data/mysql.sock |
bin日志文件目錄 | log_bin | /datalog/mysql/binlog |
relay日志文件目錄 | relay_log | /datalog/mysql/relaylog |
目前MySQL 社區的GA 提供5 和8 的下載
由于目前大多數系統用的還是5的版本
這里統一使用5的版本
注意,下面是按照5.7.21的版本安裝,5.25相同
MySQL Community Server 5.7.25
/usr/sbin/groupadd -g 105 mysql
/usr/sbin/useradd -u 105 -g mysql mysql
echo "mysql123" |passwd mysql --stdin
mkdir -p /data/mysql/software mkdir -p /usr/local/mysql mkdir -p /data/mysql/data mkdir -p /datalog/mysql/binlog mkdir -p /datalog/mysql/relaylog chown -R mysql:mysql /usr/local/mysql mkdir -p /data/mysql/tmp chown -R mysql:mysql /data/mysql chown -R mysql:mysql /datalog/mysql/
su - mysql vim ~/.bash_profile export MYSQL_HOME=/usr/local/mysql export PATH=$HOME/bin:$MYSQL_HOME/bin:$PATH export LD_LIBRARY_PATH=$MYSQL_HOME/lib:$LD_LIBRARY_PATH source ~/.bash_profile
我們這里建立 /etc/my.cnf
[mysql] user = password = [mysqld] #-----------------MySQL Basic Setting-----------------# server-id = 1723161113 port = 3306 user = mysql pid-file = mysql.pid character_set_server = utf8mb4 default_storage_engine = InnoDB skip_name_resolve = 1 lower_case_table_names = 1 explicit_defaults_for_timestamp = 1 open_files_limit = 65535 max_connections = 1000 max_connect_errors = 100000 basedir = /usr/local/mysql datadir = /data/mysql/data tmpdir = /data/mysql/tmp socket = /data/mysql/data/mysql.sock query_cache_type = query_cache_size = join_buffer_size = 64M tmp_table_size = 64M max_allowed_packet = 32M read_buffer_size = 16M read_rnd_buffer_size = 32M sort_buffer_size = 32M #-----------------MySQL Log Setting-----------------# log_error = mysql-error.log log_bin = /datalog/mysql/binlog/mysql-bin.log slow_query_log_file = mysql-slow.log relay_log = /datalog/mysql/relaylog/mysql-relay.log log_slave_updates = 1 sync_binlog = 1 relay_log_recovery = 1 binlog_format = row expire_logs_days = 14 slow_query_log = 1 long_query_time = 2 log_queries_not_using_indexes = 1 log_throttle_queries_not_using_indexes = 10 log_slow_admin_statements = 1 log_slow_slave_statements = 1 min_examined_row_limit = 1000 #-----------------MySQL Replication Setting-----------------# slave_skip_errors = ddl_exist_errors master_info_repository = TABLE relay_log_info_repository = TABLE gtid_mode = on enforce_gtid_consistency = 1 binlog_rows_query_log_events = 1 #-----------------MySQL InnoDB Setting-----------------# innodb_page_size = 16384 innodb_buffer_pool_size = 25600M innodb_data_file_path = ibdata1:1G:autoextend innodb_buffer_pool_instances = 8 innodb_file_per_table = 1 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 5 innodb_io_capacity = 800 innodb_io_capacity_max = 2000 innodb_flush_method = O_DIRECT innodb_file_format = Barracuda innodb_file_format_max = Barracuda innodb_undo_logs = 128 innodb_undo_tablespaces = 3 innodb_flush_neighbors = 1 innodb_log_file_size = 2G innodb_log_buffer_size = 16777216 innodb_print_all_deadlocks = 1 innodb_strict_mode = 1 innodb_sort_buffer_size = 67108864 #-----------------MySQL semi Replication Setting-----------------# #plugin_dir = /usr/local/mysql/lib/plugin #plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so" #loose_rpl_semi_sync_master_enabled = 1 #loose_rpl_semi_sync_slave_enabled = 1 #loose_rpl_semi_sync_master_timeout = 5000
修改my.cnf權限
chown mysql:mysql /etc/my.cnf
libaio-0.3.107-10.el6.x86_64 libaio-devel-0.3.107-10.el6.x86_64 lvm2-2.02.143-7.el6_8.1.x86_64
如果有以前版本的MySQL ,則需要先下載
如只有lib庫則可以不用動
RedHat Enterprise Linux 6適用】
# rpm -qa|grep -i mysql mysql-libs-5.1.71-1.el6.x86_64 qt-mysql-4.6.2-26.el6_4.x86_64 mysql-5.1.71-1.el6.x86_64 mysql-server-5.1.71-1.el6.x86_64 #yum remove mysql-5.1.71-1.el6.x86_64 qt-mysql-4.6.2-26.el6_4.x86_64 mysql-libs-5.1.71-1.el6.x86_64 mysql-server-5.1.71-1.el6.x86_64
【RedHat Enterprise Linux 7適用】
# rpm -qa|grep -i mariadb* mariadb-server-5.5.52-1.el7.x86_64 mariadb-libs-5.5.52-1.el7.x86_64 mariadb-embedded-5.5.52-1.el7.x86_64 mariadb-test-5.5.52-1.el7.x86_64 mariadb-bench-5.5.52-1.el7.x86_64 mariadb-5.5.52-1.el7.x86_64 mariadb-devel-5.5.52-1.el7.x86_64 mariadb-embedded-devel-5.5.52-1.el7.x86_64 # yum remove -y mariadb*
su - mysql tar xzvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql/ --strip-components=1
這里將mysql.server文件拷貝值init.d目錄使其可以當作服務啟停
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
這里修改下面幾處
vim /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/data/mysql/data lockdir='/data/mysql/data' mysqld_pid_file_path=/data/mysql/data/mysql.pid
接下來我們初始化MySQL
# su - mysql $cd /usr/local/mysql $/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
初始化過程中可以通過error文件查看進度
tail -f /data/mysql/data/mysql-error.log
$ /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql & $ netstat -lntp|grep mysqld
后續可以使用如下命令啟停數據庫
service mysqld stop
service mysqld start
service mysqld restart
設置MySQL自啟動
chkconfig mysqld on
默認密碼在error文件中有
cat /data/mysql/data/mysql-error.log |grep password
使用如下命令連接
mysql -S /data/mysql/data/mysql.sock -uroot -ppassword
感謝你能夠認真閱讀完這篇文章,希望小編分享的“MySQL 5.7.21如何在Linux平臺中安裝Part 2”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。