linux安裝mysql教程,

2021-09-05 12:45:35 字數 3450 閱讀 7665

tar -zxf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.6.42-linux-glibc2.12-x86_64 mysql

cd /usr/local/mysql

groupadd mysql

useradd -r -g mysql mysql

chown -r mysql:mysql ./

yum install libaio

chown -r root:root ./

chown -r mysql:mysql data

cd scripts

./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

cd /usr/local/mysql-5.6.27/support-filescp my-default.cnf /etc/my.cnf(修養修改my.cnf的配置,可以參照下面的配置來)

cp mysql.server /etc/init.d/mysqlvim /etc/init.d/mysql #若mysql的安裝目錄是/usr/local/mysql,則可省略此步修改檔案中的兩個變更值basedir=/usr/local/mysql-5.6.27datadir=/usr/local/mysql-5.6.27/data

13.配置環境變數

export mysql_home="/usr/local/mysql"

export path="​mysql_home/bin"

chkconfig --add mysqlchkconfig mysql on 修改服務的預設啟動等級

ps -ef|grep mysqld

啟動: service mysql start

停止: service mysql stop

重啟:service mysql restart

或者可以使用下面的命令停止mysql服務:mysqladmin -u root -p shutdown

mysqladmin -u root password '123456'

mysql -u root -p

vi /etc/sysconfig/iptables

新增檔案

iptables -i input -p tcp --dport 3306 -j accept

重啟埠

service iptables restart --重啟防火牆

[client]

port = 3306

socket = /usr/local/mysql/data/mysql.sock

[mysqld]

bind-address = 0.0.0.0

port = 3306

socket = /usr/local/mysql/data/mysql.sock

pid-file =/usr/local/mysql/data/mysql.pid

character-set-server = utf8

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

​skip-external-locking

skip-name-resolve

lower_case_table_names = 1

log-bin-trust-function-creators = 1

​max_connections = 6000

max_user_connections = 6000

max_connect_errors = 4000

wait_timeout = 86400

interactive_timeout = 86400

table_open_cache = 512

max_allowed_packet = 32m

sort_buffer_size = 2m

join_buffer_size = 2m

thread_cache_size = 8

thread_concurrency = 8

query_cache_size = 32m

#default-storage-engine = innodb

​#sql_mode="strict_all_tables,no_auto_create_user"

server-id = 1

​log-short-format

log-error = /usr/local/mysql/logs/mysql.log

slow_query_log

long_query_time = 2

slow_query_log_file = /usr/local/mysql/logs/mysql-slow.log

log_bin_trust_function_creators=1

binlog_format = mixed

expire_logs_days = 10​​

# myisam specific options

key_buffer_size = 384m

read_buffer_size = 4m

read_rnd_buffer_size = 8m

myisam_sort_buffer_size = 128m

myisam_max_sort_file_size = 1g

myisam_repair_threads = 1

myisam_recover

​[mysqldump]

quick

max_allowed_packet = 16m

​[mysql]

default-character-set = utf8

no-auto-rehash

socket = /usr/local/mysql/data/mysql.sock

​[myisamchk]

key_buffer_size = 256m

sort_buffer_size = 256m

read_buffer = 2m

write_buffer = 2m

​[mysqlhotcopy]

interactive-timeout

問題1

不允許遠端連線

is not allowed to connect mysql server

mysql -u root -p #登入mysql,需要輸入密碼

mysql>grant all privileges on . to 'root'@'%' identified by 'your_password' with grant option; #允許root使用者遠端訪問

mysql>flush privileges;

#重新整理許可權

這時候就可以遠端連線了

Linux下安裝mysql教程

最新寫了乙個小專案需要部署到遠端伺服器,就在阿里雲買了一台centos7.x的伺服器,想找個完整的教程,卻發現都是坑,要不執行到一半執行不下去,要不就是命令錯誤,經過多次踩坑總結如下 wget未安裝wget的同學執行以下命令安裝 sudo yum install wget安裝 sudo rpm iv...

linux下 安裝mysql教程

安裝環境 系統是 centos6.5 2 解壓12 34 解壓 tar zxvf mysql 5.6.33 linux glibc2.5 x86 64.tar.gz 複製解壓後的mysql目錄 cp r mysql 5.6.33 linux glibc2.5 x86 64 usr local mys...

Linux安裝MySQL教程(超詳細)

一.刪除 mysql sudo apt get autoremove purge mysql server 5.0 sudo apt get remove mysql server sudo apt get autoremove mysql server sudo apt get remove my...