一键安装mysql修改默认路径

avatar 2024年4月11日18:16:11 评论 1,045 次浏览

安装一个mysql使用一些开源的脚本一键安装的方式省时省力,这个是经过认证的多种环境安装的脚本,**wget https://soft.lnmp.com/lnmp/lnmp2.0.tar.gz -O lnmp2.0.tar.gz && tar zxf lnmp2.0.tar.gz && cd lnmp2.0 && ./install.sh db**然后根据自己的需求选择安装不同的版本

因为都是二进制安装所以下载有点慢,选择版本后继续

输入给mysql设置的root密码,然后就一路回车即可,之后最后出现安装成功的提示,这个是默认的安装方式,默认的路径是在/usr/local/mysql,启动是用/etc/init.d/mysql [start stop restart]如果修改默认路径后就会出现启动失败。

如果修改默认路径首先停止一下mysql ,然后再配置文件中修改一下数据路径,这里比如我要修改成/apps/works/server/mysql目录下,可以看一下我的配置文件修改哪些内容:

[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# cat /etc/my.cnf
[client]
#password   = your_password
port        = 3306
socket      = /tmp/mysql.sock
[mysqld]
port        = 3306
socket      = /tmp/mysql.sock
datadir = /apps/works/server/mysql/var
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
tmp_table_size = 16M
performance_schema_max_table_instances = 500
 
explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
default_authentication_plugin = mysql_native_password
 
log-bin=mysql-bin
binlog_format=mixed
server-id   = 1
binlog_expire_logs_seconds = 864000
early-plugin-load = ""
 
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /apps/works/server/mysql/var
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /apps/works/server/mysql/var
innodb_buffer_pool_size = 16M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M
 
[mysqlhotcopy]
interactive-timeout

修改成功后需要把原mysql的数据copy到新目录下,

[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# cp -R /usr/local/mysql /apps/works/server/
[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# ln -snf /data/mysql/bin/myisamchk /usr/bin/myisamchk
[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# ln -snf /data/mysql/bin/mysqlcheck /usr/bin/mysqlcheck
[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# ln -snf /data/mysql/bin/mysqldump /usr/bin/mysqldump
[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# ln -snf /data/mysql/bin/mysqld_safe /usr/bin/mysqld_safe
[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# ln -snf /data/mysql/bin/mysql /usr/bin/mysql
[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]# /etc/init.d/mysql start

启动成功,mysql配置完成,没有了,看些其他的吧。。。

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: