双MySQL,只是在节约成本的前提下,考虑使用的,更多的是在开发测试环境使用,若是生产环境,尽量不建议如此使用。
若是生产环境,森哥不建议双MySQL共存。而且,尽量建议使用提供商提供的MySQL服务。相对优化、安全、备份等,都比自搭的要好多了。像阿里云的RDS,对MySQL的开源进行二次开发的。比我们自搭的要好的多。
已安装8.0版本
网址:https://dev.mysql.com/downloads/mysql/选择OS版本,Mysql版本,这里以centos7+mysql5.7为例
备注:请选择Source Code,否则cmake会失败
拖动至最底下,选择mysql-5.7.28.tar.gz,大概为51.9M左右
tar -zxvf mysql-5.7.28.tar.gz
在安装的时,需用到boots下载:wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
tar -zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 /opt/boost
cd mysql-5.7.28
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql5.7 -DMYSQL_DATADIR=/opt/mysql5.7/data -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/opt/mysql5.7/mysqld.sock -DMYSQL_TCP_PORT=3307 -DWITH_DEBUG=0 -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/boost
make && make install
进入/opt/mysql5.7
touch /opt/mysql5.7/my.cnf
[mysqld]
user=mysql
port=3307
basedir=/opt/mysql5.7
datadir=/opt/mysql5.7/data
socket=/opt/mysql5.7/mysql.sock
lower_case_table_names=1
default-storage-engine=INNODB
character_set_server=utf8mb4
innodb_default_row_format=DYNAMIC
innodb_large_prefix=ON
innodb_file_format=Barracuda
innodb_log_file_size=2G
max_connections=500
innodb_buffer_pool_size=1G
#validate_password=off
symbolic-links=0
[client]
default-character-set=utf8mb4
socket=/opt/mysql5.7/mysql.sock
[mysqld_safe]
open-files-limit = 8192
log-error=/var/log/mysqld5.7.log
socket=/opt/mysql5.7/mysql.sock
pid-file=/opt/mysql5.7/mysqld.pid
注: 1、端口一定记得修改,不要与原来的冲突。2、下面这些配置信息,是为了用在jira系统上。根据要求增加的配置内容
default-storage-engine=INNODB
character_set_server=utf8mb4
innodb_default_row_format=DYNAMIC
innodb_large_prefix=ON
innodb_file_format=Barracuda
chown mysql.mysql -R /opt/mysql5.7
cp /opt/mysql5.7/support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
vim /etc/init.d/mysql
添加以下文件
......
basedir=/opt/mysql5.7
datadir=/opt/mysql5.7/data
......
# Try to find basedir in /etc/my.cnf
conf=/opt/mysql5.7/my.cnf
修改以下参数
把$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1&替换为:
$bindir/mysqld_safe --defaults-file=/opt/mysql5.7/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
注释掉下面这句(前面加个#即可):
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
保存退出并添加服务:
chkconfig --add /etc/init.d/mysql
/etc/init.d/mysql start
mysql5.7或以上版本的mysql,都会有一个初始化的密码,由于是非正常安装的,具体密码,也不知道是多少,也懒得去掉。就使用如下的方法,优雅的修改密码。
/etc/init.d/mysql stop
/opt/mysql5.7/bin/mysqld_safe --defaults-file=/opt/mysql5.7/my.cnf --skip-grant-tables --skip-networking &
添加--skip-networking参数,让实例关闭监听端口,自然也就无法建立TCP连接,而只能通过本地socket进行连接。
/opt/mysql5.7/bin/mysql -S /opt/mysql5.7/mysql.sock
mysql> update mysql.user set authentication_string=password('123456') where host='localhost' and user='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
注:5.7或以上的版本,使用:authentication_string5.6或以下版本,请使用:password
退出:
/opt/mysql5.7/bin/mysqld_safe --defaults-file=/opt/mysql5.7/my.cnf --skip-grant-tables --skip-networking &
/etc/init.d/mysql start