linux下安装mysql尝试其他镜像_linux下安装mysql

本文档提供了一种在Linux系统下安装MySQL 5.7的详细过程,包括下载安装脚本、设置环境变量、解压安装包、配置启动脚本以及初始化数据库。同时,还指导如何启动服务、获取并修改root用户的临时密码,以及允许root用户远程登录。
摘要由CSDN通过智能技术生成

mysql安装

1、mysql下载路径

https://pan.baidu.com/s/1MPuTenlhsX-bJrEsPD-wSw

mysql安装脚本

mysql_install-5.7.20.sh

#!/bin/bashif [ $# -ne 1]

then

echo"Usage: $0 port "exit1fi

( lsof-i:$1 &>/dev/null || which mysql$1 &>/dev/null ) && ( echo "error: the port $1 has been used" ; exit 11)

test $? -eq 11 && exit 1############################

base_dir=/usr/local/mysql$1data_dir=/mysql/mysql$1mysql_file='mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz'echo"install ing ........"############################

useradd mysql2>/dev/nullmkdir ${data_dir}-p 2>/dev/nullchown mysql:mysql ${base_dir} ${data_dir}-R

############################

#download mysql installpackageand install it

test-f $mysql_file || (echo "download mysql software package error!" ;exit 1)

test $? -eq 1 && exit 1echo"install mysql ......"tar-zxvf $mysql_file -C /usr/local

cd/usr/local && mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql$1cd ${base_dir}

ln-s ${base_dir}/support-files/mysql.server /etc/init.d/mysql$1echo'export PATH=/usr/local/mysql3306/bin:$PATH' >> /etc/profile

source/etc/profile

chown mysql:mysql ${base_dir} ${data_dir}-R

printf"[client]\nport = $1\nsocket = ${data_dir}/mysqld.sock\ndefault-character-set=utf8\n\n[mysqld]\nport = $1\nsocket = ${data_dir}/mysqld.sock\nbasedir =${base_dir} \ndatadir = ${data_dir}\nback_log = 500\nskip-name-resolve\nskip-external-locking\nconcurrent_insert = 2\ndelay-key-write = ALL\nkey_buffer_size = 256M\nmax_allowed_packet = 128M\ntable_open_cache = 512\nsort_buffer_size = 2M\nnet_buffer_length = 8K\nread_buffer_size = 2M\nread_rnd_buffer_size = 512K\nmyisam_sort_buffer_size = 64M\nthread_stack = 512K\nlog-bin = mysql-bin\nbinlog_format = mixed\nrelay_log = relay-bin\nserver-id = $1\nbinlog_cache_size = 8M\nmax_binlog_size = 1024M\nmax_relay_log_size = 1024M\nexpire_logs_days = 3\nthread_cache_size = 8\nquery_cache_size = 32M\nmax_connections = 32000\nmax_user_connections=5000\ntmp_table_size = 256M\nlong_query_time = 1\nslow_query_log\ninnodb_file_per_table\ninnodb_buffer_pool_size = 1G\ninnodb_flush_log_at_trx_commit = 2\ninnodb_flush_method = O_DIRECT\ninnodb_file_format = barracuda\ninnodb_log_file_size = 256M\ninnodb_log_files_in_group = 3\ninnodb_fast_shutdown = 1\nexplicit_defaults_for_timestamp=off\nmax_user_connections=500\nsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES\nsql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES\ninnodb_io_capacity = 2000\ninnodb_io_capacity_max = 10000\ninnodb_open_files = 1000\nfederated\nevent_scheduler=1\ndefault-storage-engine=INNODB\ncharacter-set-server=utf8\ncollation-server=utf8_general_ci\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n\n[myisamchk]\nkey_buffer_size = 20M\nsort_buffer_size = 20M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout" > /etc/my.cnf

#./scripts/mysql_install_db --defaults-file=${base_dir}/etc/my.cnf --basedir=${base_dir} --datadir=${data_dir} || exit 1${base_dir}/bin/mysqld --initialize --user=mysql --basedir=${base_dir} --datadir=${data_dir} || exit 1chown mysql:mysql ${base_dir} ${data_dir}-R/etc/init.d/mysql$1 start && echo "mysql has been install successfully!"############################

############################

chkconfig--add mysql$1chkconfig mysql$1 on

2、执行 sh mysql_install-5.7.13.sh ${MYSQL_PORT_NO} 脚本

sh mysql_install-5.7.13.sh 3306

Mysql安装时,会打印出root账户的临时密码,记下临时密码

9e22e1ebbbe52323341e4519c6f4e878.png

3、登录mysql并修改临时密码,并给root用户在其他机器可以登录的权限,在安装完成后再取消该权限。命令如下:

mysql -uroot -p

ALTER USER'root'@'localhost' IDENTIFIED BY 'root';

use mysql

update user set Host= "%" where User = "root";

至此mysql安装完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值