时间:2021-07-01 10:21:17 帮助过:27人阅读
1、Ubuntu安装MySQL所需软件包sudo apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev libcompre
1、Ubuntu安装MySQL所需软件包
sudo apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl libdb4.3-dev libpcre3 libpopt-dev lynx m4 make ncftp nmap perl perl-modules unzip zip zlib1g-dev autoconf automake1.9 libtool bison autotools-dev g++ build-essential
2、安装libncurses5-dev
sudo apt-get install libncurses5-dev
通过源码编译安装软件时,,出现错误信息:
checking for termcap functions library… configure: error: No curses/termcap library found
安装libncurses5-dev库方可解决。
3、安装MySQL
mysql使用utf-8作为默认编码:
groupadd mysql
useradd -g mysql mysql
tar -zxvf mysql-5.0.45.tar.gz
cd mysql-5.0.45
./configure –prefix=/usr/local/mysql –with-charset=utf8 –with-collation=utf8_general_ci –with-extra-charsets=latin1
make
make install
vi my.cnf
输入代码:
[client]
default-character-set = utf8
port = 3306
socket = /tmp/mysql.sock
[mysql]
prompt="(\u:Molutran's MySQL Server:)[\d]> "
no-auto-rehash
[mysqld]
#default-character-set = utf8
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
open_files_limit = 10240
back_log = 600
max_connections = 3000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 300
thread_concurrency = 8
query_cache_size = 32M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
default_table_type = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 1
log_long_format
log-bin = /usr/local/mysql/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 512M
expire_logs_days = 7
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
skip-name-resolve
master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
server-id = 1
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2048M
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
[mysqldump]
quick
max_allowed_packet = 32M
4、给MySQL安装目录加写权限并改变属组
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
5、附带修改root用户密码
mysql>use mysql
mysql>UPDATE user SET password=PASSWORD('new_password') WHERE user='root';
mysql>FLUSH PRIVILEGES;
mysql>exit