linux伺服器安裝配置mysql

2021-10-11 02:33:56 字數 3576 閱讀 2418

目的:伺服器安裝配置mysql實施記錄,下次有需要備查。

useradd mysql

passwd mysql #這裡輸入密碼,注意記錄密碼

mkdir /opt/mysql

tar -zxvf mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz -c /opt/mysql

cd /opt/mysql

mv mysql-5.6.41-linux-glibc2.12-x86_64/* .

rm -rf mysql-5.6.41-linux-glibc2.12-x86_64/

yum -y install perl perl-devel gcc kernel-devel autoconf

chown -r mysql:mysql /opt/mysql/
su - mysql

cd /opt/mysql

/opt/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data

注意,如果安裝報錯:scripts/mysql_install_db: /usr/bin/perl: bad interpreter: no such file or directory

需要切換到root使用者,安裝perl以及perl-devel,執行下面命令:

yum -y install perl perl-devel)

touch mysql_error.log
切換到root使用者

複製檔案:

su - root

cd /opt/mysql/support-files

cp my-default.cnf /etc/my.cnf

cat /dev/null > /etc/my.cnf

vi /etc/my.cnf

#全部刪除,改為如下:

[mysqld]

# port=33060

basedir = /opt/mysql

datadir = /opt/mysql/data

socket = /tmp/mysql.sock

log-error=/opt/mysql/mysql_error.log

skip-name-resolve

character_set_server=utf8

character_set_client=utf8

collation-server=utf8_general_ci

#init_connect='set names utf8'

sql_mode=no_engine_substitution,strict_trans_tables

lower_case_table_names = 1

max_allowed_packet = 32m

table_open_cache = 1024

sort_buffer_size = 4m

join_buffer_size = 2m

net_buffer_length = 8m

read_buffer_size = 4m

read_rnd_buffer_size = 8m

thread_cache_size = 300

query_cache_size = 1024m

query_cache_limit = 2m

thread_concurrency = 8

wait_timeout = 315360000

max_connections = 300

max_connect_errors=1844674407370954751

max_connect_errors = 10000

#event_scheduler=1

#innodb_log_file_size=256m

innodb_buffer_pool_size = 4094m

innodb_additional_mem_pool_size = 32m

innodb_log_file_size = 1024m

innodb_log_files_in_group = 2

innodb_log_buffer_size = 8m

#innodb_flush_log_at_trx_commit = 2

innodb_lock_wait_timeout = 50

innodb_thread_concurrency=8

#innodb_sort_buffer_size=32m

innodb_open_files=4096

innodb_write_io_threads=2

innodb_read_io_threads=2

innodb_max_dirty_pages_pct = 90

innodb_file_per_table=1

[client]

socket=/tmp/mysql.sock

default-character-set=utf8

#結束

cp mysql.server /etc/init.d/mysql

vi /etc/init.d/mysql

#修改檔案中的兩個變更值

basedir=/opt/mysql/

datadir=/opt/mysql/data/

vi /etc/profile

#新增如下內容:

export path=

$path:/opt/mysql/bin

source /etc/profile

chkconfig --add mysql

chkconfig mysql on

service mysql start

starting mysql… success!

/opt/mysql/bin/mysqladmin -u root password 'yourpasswd'

# 這裡輸入密碼,注意記錄密碼

# mysql root使用者登入

mysql -uroot -pyourpasswd

注意這裡的資料庫root使用者密碼不要和linux使用者mysql的密碼混淆了

設定後可通過客戶端連線

#>sql

grant

allprivilegeson*

.*to'root'@'%

' identified by 'yourpasswd';

flush privileges

;

Linux伺服器安裝配置tomcat

安裝jdk 請參考linux安裝配置jdk 新增catalina home 在 etc profile檔案末尾新增,opt apache為tomcat所在路徑 catalina home opt apache 使配置生效 source etc profile 啟動tomcat 進入tomcat目錄下...

linux伺服器安裝配置nodejs

在終端上傳安裝檔案 scp node v10.8.0 linux x64.tar.xz root 伺服器ip root tools,回車,輸入密碼 進入伺服器 ssh root 伺服器ip,回車,輸入密碼 tar root tools node v10.8.0 linux x64.tar.xz,會生...

LInux安裝配置NFS伺服器

centos yum install rpcbind nfs utils ubuntu 14.04 apt get install nfs kernel server rpcbind mkdir data nfs vim etc exports,增加 data nfs rw,sync,no root...