Bandwagon 安装 Mysql 数据库

时间:2024-04-15 20:07:46

Bandwagon 安装 Mysql 数据库

1.搬瓦工系统准备

建议使用版本Centos6 x86_64,安装完成后,使用远程登陆软件登陆。

Bandwagon 安装 Mysql 数据库

2.安装编译工具及库文件

yum -y install gcc gcc-c++ make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip libmcrypt-devel libmhash-devel ncurses-devel sudo bzip2 flex libaio-devel

3.安装wget

yum -y install wget

4.安装cmake 编译器

 4.1下载

$ wget http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz

4.2解压安装包

$ tar zxvf cmake-3.1..tar.gz

4.3编译安装 

$ cd cmake-3.1.
$ ./bootstrap
$ make && make install

5.安装 MySQL

5.1mysql数据库需要安装 source 版本,否则 cmake会报错

$ wget  https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.43.tar.gz

 5.2解压安装包

$ tar zxvf mysql-5.6..tar.gz
$ cd mysql-5.6.

5.3编译安装

$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE= -DWITH_INNOBASE_STORAGE_ENGINE= -DWITH_MEMORY_STORAGE_ENGINE= -DWITH_READLINE= -DWITH_INNODB_MEMCACHED= -DWITH_DEBUG=OFF -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE= -DENABLED_PROFILING=ON -DMYSQL_MAINTAINER_MODE=OFF -DMYSQL_DATADIR=/usr/local/webserver/mysql/data -DMYSQL_TCP_PORT=
$ make && make install

5.4 查看Mysql版本

$ /usr/local/webserver/mysql/bin/mysql --version

6.MySQL 配置

6.1创建mysql运行使用的用户mysql

$ /usr/sbin/groupadd mysql
$ /usr/sbin/useradd -g mysql mysql

6.2创建binlog和库的存储路径并赋予mysql用户权限

$ mkdir -p /usr/local/webserver/mysql/binlog /www/data_mysql
$ chown mysql.mysql /usr/local/webserver/mysql/binlog/ /www/data_mysql/

6.3创建my.cnf配置文件,将/etc/my.cnf替换为下面内容

$ cat /etc/my.cnf

[client]
port =
socket = /tmp/mysql.sock
[mysqld]
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user = mysql
port =
socket = /tmp/mysql.sock
basedir = /usr/local/webserver/mysql
datadir = /www/data_mysql
log-error = /usr/local/webserver/mysql/mysql_error.log
pid-file = /usr/local/webserver/mysql/mysql.pid
open_files_limit =
back_log =
max_connections =
max_connect_errors =
table_open_cache =
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size =
#thread_concurrency =
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
default-tmp-storage-engine=MYISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 128M
max_heap_table_size = 128M
log-slave-updates
log-bin = /usr/local/webserver/mysql/binlog/binlog
binlog-do-db=oa_fb
binlog-ignore-db=mysql
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /usr/local/webserver/mysql/relaylog/relaylog
relay-log-info-file = /usr/local/webserver/mysql/relaylog/relaylog
relay-log = /usr/local/webserver/mysql/relaylog/relaylog
expire_logs_days =
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_repair_threads =
myisam_recover
interactive_timeout =
wait_timeout =
skip-name-resolve
#master-connect-retry =
slave-skip-errors = ,,,,,,
#master-host = 192.168.1.2
#master-user = username
#master-password = password
#master-port =
server-id =
loose-innodb-trx=
loose-innodb-locks=
loose-innodb-lock-waits=
loose-innodb-cmp=
loose-innodb-cmp-per-index=
loose-innodb-cmp-per-index-reset=
loose-innodb-cmp-reset=
loose-innodb-cmpmem=
loose-innodb-cmpmem-reset=
loose-innodb-buffer-page=
loose-innodb-buffer-page-lru=
loose-innodb-buffer-pool-stats=
loose-innodb-metrics=
loose-innodb-ft-default-stopword=
loose-innodb-ft-inserted=
loose-innodb-ft-deleted=
loose-innodb-ft-being-deleted=
loose-innodb-ft-config=
loose-innodb-ft-index-cache=
loose-innodb-ft-index-table=
loose-innodb-sys-tables=
loose-innodb-sys-tablestats=
loose-innodb-sys-indexes=
loose-innodb-sys-columns=
loose-innodb-sys-fields=
loose-innodb-sys-foreign=
loose-innodb-sys-foreign-cols= slow_query_log_file=/usr/local/webserver/mysql/mysql_slow.log
long_query_time =
[mysqldump]
quick
max_allowed_packet = 32M

6.4初始化数据库

$/usr/local/webserver/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf  --user=mysql

6.5启动mysql服务器

$ service mysqld start

6.6连接MySql

该版本数据库默认没有密码,回车即可。

$ /usr/local/webserver/mysql/bin/mysql -u root -p

6.7 修改数据库密码

。。。

6.8远程访问配置

6.8.1 修改/etc/my.cnf 中的3306为其他端口号

6.8.2设置远程访问权限

选择数据库

use mysql;

查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称)

select 'host' from user where user='root'; 

修改host值(以通配符%的内容增加主机/IP地址)

update user set host = '%' where user ='root';  

刷新MySQL的系统权限相关表

flush privileges; 

再重新查看user表时,有修改

select 'host'   from user where user='root'; 

注意:ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 忽略

6.9远程登陆测试

6.9.1安装Sqlyog

6.9.2远程登陆测试

Bandwagon 安装 Mysql 数据库

7.常见问题

7.1重启服务错误 The server quit without updating PID file

绿色版mysql Linux环境下安装时,去掉了etc/my.cnf中的 注释导致,添加上即可

Bandwagon 安装 Mysql 数据库

7.2其他命令

    启动:service mysqld start
停止:service mysqld stop
重启:service mysqld restart
重载配置:service mysqld reload
创建开机启动脚本

$ cd /usr/local/webserver/mysql/
$ cp support-files/mysql.server /etc/rc.d/init.d/mysqld
$ chkconfig --add mysqld
$ chkconfig --level mysqld on

参考:

http://www.cnblogs.com/chusiping/archive/2011/11/10/2243805.html

http://www.runoob.com/linux/mysql-install-setup.html

https://www.cnblogs.com/java-wgm/p/6264767.html

http://blog.51cto.com/732233048/1636409

https://www.cnblogs.com/lvlv/p/4173798.html