solaris10 安装mysql并修改data存放位置
#uname -a
SunOS NBI 5.10 Generic_127127-11 sun4u sparc SUNW,Sun-Fire-V890
#isainfo -v
64-bit sparcv9 applications
vis2 vis popc
32-bit sparc applications
vis2 vis popc v8plus div32 mul32
#isainfo -v -b
64-bit sparcv9 applications
vis2 vis popc
sparc 64bit
下载这种mysql-5.5.47-solaris10-sparc-64bit.pkg.gz
gzip -d
/var/sadm/install/admin修改default权限,修改最后一行,
root权限pkgadd安装 pkgadd -d mysql-5.5.1.....pkg
/opt/nbi/DataFile/ce_monitor/mysql/bin/mysqladmin -u root password 'new-password'
/opt/nbi/DataFile/ce_monitor/mysql/bin/mysqladmin -u root -h NBI password 'new-password'(推荐)
/opt/nbi/DataFile/ce_monitor/mysql/bin/mysql -u root -h NBI -p
===================================================================
更改mysql的data位置
show variables like 'datadir';
你会看到默认的是在/var/lib/mysql
修改mysql的data路径:方法是,在/etc/init.d/mysql里的basedir,datadir,和my.cnf的位置
第46/47行
basedir=
datadir=
更改为你安装的位置和要存放的位置,
basedir=/opt/.../mysql
datadir=/opt/.../mysql/data/mysql
第214行
conf=/etc/my.cnf
改为你配置文件存放路径,我保存在安装路径里的
conf=/opt/.../mysql/my.cnf
到安装的路径/opt/.../mysql下
bin/mysqld_safe --user=root &
数据库就可以起来了
show variables like 'datadir';验证已经移到/opt/.../mysql/data/mysql下
show status like 'Innodb_buffer_pool_%';
===========================================================================
杀进程关闭mysql
跳过验证,密码
bin/mysqld_safe --user=root --skip-grant-tables --skip-networking &
免验证登陆
/opt/nbi/DataFile/ce_monitor/mysql/bin/mysql -u root
===========================================================================
找到配置文件的位置(生效顺序是从前往后找,前面的生效后面就不找了)
[root@NBI:/opt/nbi/DataFile/ce_monitor/mysql]#/bin/mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /opt/mysql/mysql/etc/my.cnf ~/.my.cnf
修改配置文件优化内存
vi /etc/my.cnf
back_log = 384
key_buffer_size = 256M
max_allowed_packet = 4M
thread_stack = 256K
table_cache = 128K
sort_buffer_size = 6M
read_buffer_size = 4M
join_buffer_size = 8M
myisam_sort_buffer_size = 64M
table_cache = 512
thread_cache_size = 64
query_cache_size = 64M
tmp_table_size = 256M
max_connections = 768
max_connect_errors = 10000000
wait_timeout = 10
thread_concurrency = 8
table_cache=1024
innodb_additional_mem_pool_size=4M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=2M
innodb_thread_concurrency=8
key_buffer_size=256M
tmp_table_size=64M
read_buffer_size=4M
read_rnd_buffer_size=16M
sort_buffer_size=32M
thread_cache_size=120
query_cache_size=32M