189 8069 5689

AliSQL-5.6.32编译安装

1、系统环境 CentOS 6.8_X64

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:国际域名空间、网页空间、营销软件、网站建设、屏边网站维护、网站推广。

2、需要的软件mirrors-alisql-master.zip 以及需要的依赖包centos-release-scl devtoolset-4-gcc-c++ devtoolset-4-gcc ncurses-devel openssl-devel bison git cmake

3、安装需要的依赖软件包

yum -y install centos-release-scl devtoolset-4-gcc-c++ devtoolset-4-gcc ncurses-devel openssl-devel bison git cmake

4、下载 mirrors-alisql-master.zip

https://github.com/alibaba/AliSQL

5、解压mirrors-alisql-master.zip

unzip mirrors-alisql-master.zip

6、创建MySQL用户组和用户,及数据库存放目录:

mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/tmp
mkdir -p /var/log/mysql
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /var/log/mysql

7、编译安装

cd alisql

cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DCMAKE_BUILD_TYPE="Release" \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_TOKUDB_STORAGE_ENGINE=0 \
-DENABLE_DTRACE=0 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DEXTRA_CHARSETS=all \
-DMYSQL_USER=mysql \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=OFF \
-DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF

scl enable devtoolset-4 bash #在配置前,要先设置下环境变量,这样才能用到 devtoolset-4 套装里的gcc

make -j4 && make install #-j4 表示开 4 个并发编译进程,加速编译,根据机器 CPU 核数调整,一般是 CPU 核数 + 1

8、编辑配置文件

[client]
port = 3306
socket = /usr/local/mysql/mysql.sock
default-character-set = utf8mb4

[mysql]
prompt="AliSQL [\d]> "
#no-auto-rehash

[mysqld]
port = 3306
user = mysql
skip-name-resolve
socket = /usr/local/mysql/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/mysql.pid
tmpdir = /usr/local/mysql/tmp
slave-load-tmpdir = /usr/local/mysql/tmp
log_error = /var/log/mysql/mysqld.log
#secure-file-priv = /usr/local/mysql/uploads

#慢查询
slow_query_log = 1
long_query_time = 2
log-queries-not-using-indexes
slow_query_log_file = /var/log/mysql/mysql_slow.log

log-slow-admin-statements = 1
log-slow-slave-statements = 1
log-bin-trust-function-creators = 1

#init-connect = 'SET NAMES utf8'
#character-set-server = utf8
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
symbolic-links = 0
#lower_case_table_names = 1
performance_schema = 0
#bind-address = 0.0.0.0
#开启查询缓存
explicit_defaults_for_timestamp=true

#消耗系统IO 内存等
#log-output = FILE
#general_log = off
#general_log_file = /var/log/mysql/general.log

##^^^^^^^^^^^^^^^^^^^^^^主从同步相关设置开始^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^##
server-id = 10
binlog_cache_size = 4M
max_binlog_size = 1G
max-binlog-cache-size = 2G
max-relay-log-size = 1G
log_bin = /var/log/mysql/mysql-master-bin
binlog_format = mixed
log_bin_index = /var/log/mysql/bin_log.index
expire_logs_days = 90

#skip-locking
#禁止外网
#skip-networking
#禁止域名解析
skip-name-resolve
#skip-grant-tables
#禁止锁定
skip-external-locking
skip_show_database
skip_symbolic_links

back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
#表缓存数
table_open_cache = 128
binlog_cache_size = 1M
#最大表量
max_heap_table_size = 256M
tmp_table_size = 16M
#根据物理内存设置规则如下:1G=8 ; 2G=16; 3G=32; 3G>= =64
thread_cache_size = 16
open-files-limit=8192
#排序缓冲
sort_buffer_size=256M

#启动高速缓存
query_cache_type = 1
#查询缓存 很少有相同的查询,最好不要使用查询缓存
query_cache_size = 128M
query_cache_limit = 2M

flush_time = 0
#连续缓冲
join_buffer_size = 16M

group_concat_max_len=2048000
table_definition_cache = 1400

ft_min_word_len = 4
#预读缓冲
read_buffer_size = 2M
#次缓冲
read_rnd_buffer_size = 64M
query_cache_min_res_unit = 1MB
bulk_insert_buffer_size = 8M
#索引缓冲 比较理想的设置:Key_blocks_used / (Key_blocks_unused + Key_blocks_used) * 100% ≈ 80%
key_buffer_size=64M

#default-storage-engine = MyISAM
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
#参数的配置在物理内存的70%-80%之间
innodb_buffer_pool_size = 64M
#InnoDB 使用后台线程处理数据页上写 I/O(输入)请求的数量
innodb_write_io_threads = 4
#InnoDB 使用后台线程处理数据页上读 I/O(输出)请求的数量
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
#日志缓冲池,控制在8M-16M即可
innodb_log_buffer_size = 2M
#InnoDB 日志文件的大小
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
#控制了 Dirty Page 在 Buffer Pool 中所占的比率
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
#缓冲区刷新到磁盘时,刷新脏页数量,ssd磁盘,或做了raid后,可将此值设置较大
innodb_io_capacity = 200
innodb_adaptive_flushing = OFF

innodb_autoextend_increment = 64
innodb_buffer_pool_instances = 8
innodb_concurrency_tickets = 5000
innodb_old_blocks_time = 1000
innodb_stats_on_metadata = 0

myisam_sort_buffer_size = 16M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

#导入大的sql文件的方法
interactive_timeout = 28800
wait_timeout = 28800
connect_timeout = 20
#单数据包
max_allowed_packet = 500M
#thread_concurrency = 8

[mysqlhotcopy]
interactive-timeout

[mysqldump]
quick
max_allowed_packet = 500M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

[mysqld_safe]
log_error = /var/log/mysql/mysqld.log
pid-file = /usr/local/mysql/mysql.pid

chown mysql.mysql /etc/my.cnf

chmod 600 /etc/my.cnf

9、初始化数据库:(初始化的时候要注意,会生成一个root的随机密码,后面登录会用到)

chmod 777 scripts/mysql_install_db

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --defaults-file=/etc/my.cnf

10、设置环境变量

vim /etc/profile

export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

11、复制 mysql 服务启动配置文件

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod a+x /etc/init.d/mysqld

12、启动数据库进程

service mysqld start

13、修改root密码,设置远程登录

mysql -u root

AliSQL [mysql]>use mysql;
AliSQL [mysql]>select host, user from user;
AliSQL [mysql]>update user set password=PASSWORD('rootoo')where user='root';
AliSQL [mysql]>update user set host = '%' where user = 'root'; #授权远程登录用户名为root,如果报错,ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY',不予理会
AliSQL [mysql]>flush privileges;

AliSQL [mysql]>grant all on . to "root"@"172.30.41.72" identified by "123456"; #授权172.30.41.72以root用户远程登录访问数据库,root密码为123456
AliSQL [mysql]>grant all on . to "root"@"%" identified by "123456"; #授权所有ip都可以以root用户远程登录访问数据库,root密码为123456
AliSQL [mysql]>grant all on . to "root"@"localhost" identified by "123456"; #授权localhost以root用户远程登录访问数据库,root密码为123456

AliSQL [mysql]>select user from user; #查看所有用户

14、重启mysql

service mysqld restart
chkconfig mysqld on

15、下载phpMyAdmin

wget https://files.phpmyadmin.net/phpMyAdmin/4.7.0/phpMyAdmin-4.7.0-all-languages.zip

16、解压phpMyAdmin-4.7.0-all-languages.zip

unzip phpMyAdmin-4.7.0-all-languages.zip

17、打开libraries下的config.default.php文件,依次找到下面各项,按照说明配置即可:

a.访问网址

$cfg['pmaabsoluteuri'] = '192.168.1.5';这里填写phpmyadmin的访问网址

b.mysql主机信息

$cfg['servers'][$i]['host'] = 'localhost'; // mysql hostname or ip address

填写localhost或mysql所在服务器的ip地址,如果mysql和该phpmyadmin在同一服务器,则按默认localhost

$cfg['servers'][$i]['port'] = ''; // mysql port - leave blank for default port

mysql端口,如果是默认3306,保留为空即可

c.mysql用户名和密码

$cfg['servers'][$i]['user'] = 'root'; // mysql user访问phpmyadmin使用的mysql用户名

fg['servers'][$i]['password'] = 'rootoo'; // mysql password (only needed对应上述mysql用户名的密码
d.认证方法

$cfg['servers'][$i]['auth_type'] = 'http';

在此有四种模式可供选择,cookie,http,http,config

config方式即输入phpmyadmin的访问网址即可直接进入,无需输入用户名和密码,是不安全的,不推荐使用。

当该项设置为cookie,http或http时,登录phpmyadmin需要数据用户名和密码进行验证,,具体如下:

php安装模式为nginx/apache,可以使用http和cookie;

php安装模式为cgi,可以使用cookie

e.短语密码(blowfish_secret)的设置

$cfg['blowfish_secret'] = '';

如果认证方法设置为cookie,就需要设置短语密码,但是不能留空,否则会在登录phpmyadmin时提示错误

f.配置

1、打开 /libraries/config.default.php文件(旧版本是根目录下的config.inc.php文件),用写字板(不要用记事本,这是utf8编码)进行编辑,按照说明配置即可。

2、查找 $cfg['pmaabsoluteuri']=‘'; // 修改为你将上传到空间的phpmyadmin的网址

如:$cfg['pmaabsoluteuri'] =‘http: // 网站域名/phpmyadmin/';

3、查找 $cfg['servers'][$i]['host'] =‘localhost'; // 通常用默认,也有例外,可以不用修改

4、查找 $cfg['servers'][$i]['auth_type'] =‘config'; // 在自己的机子里调试用config;如果在网络上的空间用cookie.

18、http://192.168.1.5/phpMyAdmin/ 输入用户名root密码rootoo后,访问正常

常见的错误:#2002 - Permission denied — 服务器没有响应(或本地服务器的套接字没有正确设置)。
报错原因:如果未指定指定主机名或指定了特殊的主机名localhost,将使用Unix套接字。
Unix套接字默认为/tmp/mysql.sock,如果没有配置这样的套接字文件或者配置不正确,所以自然是连接失败了。
解决方法:$cfg['servers'][$i]['host'] =‘localhost';改为$cfg['servers'][$i]['host'] =‘127.0.0.1';


网页名称:AliSQL-5.6.32编译安装
分享地址:http://cdxtjz.com/article/ihoodg.html

其他资讯