mysql多实例

[root@localhost~]# vim /etc/yum.repos.d/rhel7.repo

[root@localhost~]# yum repolist

已加载插件:langpacks,product-id, search-disabled-repos, subscription-manager

Thissystem is not registered with an entitlement server. You can usesubscription-manager to register.

rhel7 | 4.1 kB 00:00:00

(1/2):rhel7/group_gz | 137 kB 00:00:00

(2/2):rhel7/primary_db | 4.0 MB 00:00:00

源标识 源名称 状态

rhel7 rhel7 4,986

repolist:4,986

[root@localhost~]# rpm -qa | grep -i mariadb

mariadb-libs-5.5.56-2.el7.x86_64

[root@localhost~]# systemctl stop mariadb

Failedto stop mariadb.service: Unit mariadb.service not loaded.

[root@localhost~]# rpm -e --nodeps mariadb-server mariadb

错误:未安装软件包mariadb-server

错误:未安装软件包mariadb

[root@localhost~]# ls /etc/my.cnf

/etc/my.cnf

[root@localhost~]# ls /var/lib/mysql

ls:无法访问/var/lib/mysql:没有那个文件或目录

[root@localhost~]# tar -xf mysql-5.7.17.tar

[root@localhost~]# ls

anaconda-ks.cfg

initial-setup-ks.cfg

mysql-5.7.17.tar

mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

mysql-community-client-5.7.17-1.el7.x86_64.rpm

mysql-community-common-5.7.17-1.el7.x86_64.rpm

mysql-community-devel-5.7.17-1.el7.x86_64.rpm

mysql-community-embedded-5.7.17-1.el7.x86_64.rpm

mysql-community-embedded-compat-5.7.17-1.el7.x86_64.rpm

mysql-community-embedded-devel-5.7.17-1.el7.x86_64.rpm

mysql-community-libs-5.7.17-1.el7.x86_64.rpm

mysql-community-libs-compat-5.7.17-1.el7.x86_64.rpm

mysql-community-minimal-debuginfo-5.7.17-1.el7.x86_64.rpm

mysql-community-server-5.7.17-1.el7.x86_64.rpm

mysql-community-test-5.7.17-1.el7.x86_64.rpm

公共

模板

视频

图片

文档

下载

音乐

桌面

[root@localhost~]# yum -y install perl-JSON

已加载插件:langpacks,product-id, search-disabled-repos, subscription-manager

Thissystem is not registered with an entitlement server. You can usesubscription-manager to register.

正在解决依赖关系

-->正在检查事务

--->软件包 perl-JSON.noarch.0.2.59-2.el7将被 安装

-->解决依赖关系完成


依赖关系解决


==============================================================================================================

Package 架构 版本 源 大小

==============================================================================================================

正在安装:

perl-JSON noarch 2.59-2.el7 rhel7 96 k


事务概要

==============================================================================================================

安装 1 软件包


总下载量:96k

安装大小:264k

Downloadingpackages:

perl-JSON-2.59-2.el7.noarch.rpm | 96 kB 00:00:00

Runningtransaction check

Runningtransaction test

Transactiontest succeeded

Runningtransaction

正在安装 :perl-JSON-2.59-2.el7.noarch 1/1

rhel7/productid | 1.6 kB 00:00:00

验证中 :perl-JSON-2.59-2.el7.noarch 1/1


已安装:

perl-JSON.noarch0:2.59-2.el7


完毕!

[root@localhost~]# rpm -Uvh mysql-community-*.rpm

警告:mysql-community-client-5.7.17-1.el7.x86_64.rpm:V3DSA/SHA1 Signature, 密钥 ID5072e1f5: NOKEY

准备中... ################################# [100%]

正在升级/安装...

1:mysql-community-common-5.7.17-1.e#################################[ 8%]

2:mysql-community-libs-5.7.17-1.el7#################################[ 17%]

3:mysql-community-client-5.7.17-1.e#################################[ 25%]

4:mysql-community-server-5.7.17-1.e#################################[ 33%]

5:mysql-community-devel-5.7.17-1.el#################################[ 42%]

6:mysql-community-embedded-5.7.17-1#################################[ 50%]

7:mysql-community-embedded-devel-5.#################################[ 58%]

8:mysql-community-test-5.7.17-1.el7#################################[ 67%]

9:mysql-community-libs-compat-5.7.1#################################[ 75%]

10:mysql-community-embedded-compat-5#################################[ 83%]

11:mysql-community-minimal-debuginfo#################################[ 92%]

正在清理/删除...

12:mariadb-libs-1:5.5.56-2.el7 ################################# [100%]

[root@localhost~]# rpm -qa | grep -i mysql

mysql-community-client-5.7.17-1.el7.x86_64

mysql-community-minimal-debuginfo-5.7.17-1.el7.x86_64

mysql-community-test-5.7.17-1.el7.x86_64

mysql-community-common-5.7.17-1.el7.x86_64

mysql-community-devel-5.7.17-1.el7.x86_64

mysql-community-libs-compat-5.7.17-1.el7.x86_64

mysql-community-libs-5.7.17-1.el7.x86_64

mysql-community-embedded-5.7.17-1.el7.x86_64

mysql-community-embedded-compat-5.7.17-1.el7.x86_64

mysql-community-embedded-devel-5.7.17-1.el7.x86_64

mysql-community-server-5.7.17-1.el7.x86_64

[root@localhost~]# ls /etc/my.cnf

/etc/my.cnf

[root@localhost~]# systemctl start mysqld

[root@localhost~]# systemctl enable mysqld

[root@localhost~]# ps -C mysqld

PIDTTY TIME CMD

2266? 00:00:00 mysqld

[root@localhost~]# netstat -utnlp | grep mysqld

tcp6 0 0 :::3306 :::* LISTEN 2266/mysqld

[root@localhost~]# grep password /var/log/mysqld.log

2018-07-05T13:34:53.289436Z1 [Note] A temporary password is generated for root@localhost:gwvVh6eM6H&k

[root@localhost~]# mysql -hlocalhost -uroot -p'gwvVh6eM6H&k'

mysql:[Warning] Using a password on the command line interface can beinsecure.

Welcometo the MySQL monitor. Commands end with ; or \g.

YourMySQL connection id is 3

Serverversion: 5.7.17


Copyright(c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracleis a registered trademark of Oracle Corporation and/or its

affiliates.Other names may be trademarks of their respective

owners.


Type'help;' or '\h' for help. Type '\c' to clear the current inputstatement.


mysql>set global validate_password_policy=0;

QueryOK, 0 rows affected (0.00 sec)


mysql>set global validate_password_length=6;

QueryOK, 0 rows affected (0.00 sec)


mysql>alter user root@"localhost" identified by

->

->"123456"

->\c

mysql>alter user root@"localhost" identified by "123456"

->\c

mysql>alter user root@"localhost" identified by "123456";

QueryOK, 0 rows affected (0.00 sec)


mysql>\q

Bye

[root@localhost~]# mysql -hlocalhost -uroot -p123456

mysql:[Warning] Using a password on the command line interface can beinsecure.

Welcometo the MySQL monitor. Commands end with ; or \g.

YourMySQL connection id is 4

Serverversion: 5.7.17 MySQL Community Server (GPL)


Copyright(c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracleis a registered trademark of Oracle Corporation and/or its

affiliates.Other names may be trademarks of their respective

owners.


Type'help;' or '\h' for help. Type '\c' to clear the current inputstatement.


mysql>show databases;

+--------------------+

|Database |

+--------------------+

|information_schema |

|mysql |

|performance_schema |

|sys |

+--------------------+

4rows in set (0.00 sec)


mysql>\q

Bye

[root@localhost~]# vim /etc/my.cnf

[root@localhost~]# systemctl restart mysqld

[root@localhost~]# mysql -hlocalhost -uroot -p123456

mysql:[Warning] Using a password on the command line interface can beinsecure.

Welcometo the MySQL monitor. Commands end with ; or \g.

YourMySQL connection id is 3

Serverversion: 5.7.17 MySQL Community Server (GPL)


Copyright(c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracleis a registered trademark of Oracle Corporation and/or its

affiliates.Other names may be trademarks of their respective

owners.


Type'help;' or '\h' for help. Type '\c' to clear the current inputstatement.


mysql>\q

Bye

[root@localhost~]# systemctl status mysqld

mysqld.service - MySQLServer

Loaded: loaded(/usr/lib/systemd/system/mysqld.service; enabled; vendor preset:disabled)

Active: active(running) since 2018-07-0521:38:28 CST; 35s ago

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

Process: 2384ExecStart=/usr/sbin/mysqld --daemonize--pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited,status=0/SUCCESS)

Process: 2362ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited,status=0/SUCCESS)

MainPID: 2388 (mysqld)

CGroup:/system.slice/mysqld.service

└─2388/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid


705 21:38:26localhost.localdomain systemd[1]: Starting MySQL Server...

705 21:38:28localhost.localdomain systemd[1]: Started MySQL Server.

[root@localhost~]# systemctl stop mysqld

[root@localhost~]# rpm -qa | grep -i mysql

mysql-community-client-5.7.17-1.el7.x86_64

mysql-community-minimal-debuginfo-5.7.17-1.el7.x86_64

mysql-community-test-5.7.17-1.el7.x86_64

mysql-community-common-5.7.17-1.el7.x86_64

mysql-community-devel-5.7.17-1.el7.x86_64

mysql-community-libs-compat-5.7.17-1.el7.x86_64

mysql-community-libs-5.7.17-1.el7.x86_64

mysql-community-embedded-5.7.17-1.el7.x86_64

mysql-community-embedded-compat-5.7.17-1.el7.x86_64

mysql-community-embedded-devel-5.7.17-1.el7.x86_64

mysql-community-server-5.7.17-1.el7.x86_64

[root@localhost~]# systemctl disable mysqld

Removedsymlink /etc/systemd/system/multi-user.target.wants/mysqld.service.

[root@localhost~]# ls mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

[root@localhost~]# tar -zxf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

[root@localhost~]# systemctl status mysqld

mysqld.service - MySQLServer

Loaded: loaded(/usr/lib/systemd/system/mysqld.service; disabled; vendor preset:disabled)

Active: inactive(dead)

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html


705 21:34:42localhost.localdomain systemd[1]: Starting MySQL Server...

705 21:35:14localhost.localdomain systemd[1]: Started MySQL Server.

705 21:38:25localhost.localdomain systemd[1]: Stopping MySQL Server...

705 21:38:26localhost.localdomain systemd[1]: Starting MySQL Server...

705 21:38:28localhost.localdomain systemd[1]: Started MySQL Server.

705 21:39:12localhost.localdomain systemd[1]: Stopping MySQL Server...

705 21:39:14localhost.localdomain systemd[1]: Stopped MySQL Server.

[root@localhost~]# ls mysql-5.7.20*

mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz


mysql-5.7.20-linux-glibc2.12-x86_64:

bin COPYING docs include lib man README share support-files

[root@localhost~]# mv mysql-5.7.20-linux-glibc2.12-x86_64 /usr/local/mysql

[root@localhost~]# cd /usr/local/mysql

[root@localhostmysql]# ls bin

innochecksum mysqlcheck mysql_embedded mysql_tzinfo_to_sql

lz4_decompress mysql_client_test_embedded mysqlimport mysql_upgrade

myisamchk mysql_config mysql_install_db mysqlxtest

myisam_ftdump mysql_config_editor mysql_plugin perror

myisamlog mysqld mysqlpump replace

myisampack mysqld-debug mysql_secure_installation resolveip

my_print_defaults mysqld_multi mysqlshow resolve_stack_dump

mysql mysqld_safe mysqlslap zlib_decompress

mysqladmin mysqldump mysql_ssl_rsa_setup

mysqlbinlog mysqldumpslow mysqltest_embedded

[root@localhostmysql]# mysql

mysql mysqld mysql_secure_installation

mysqladmin mysqld-debug mysqlshow

mysqlbinlog mysqld_pre_systemd mysqlslap

mysqlcheck mysqldump mysql_ssl_rsa_setup

mysql_client_test mysqldumpslow mysqltest

mysql_client_test_embedded mysqlimport mysqltest_embedded

mysql_config mysql_install_db mysql_tzinfo_to_sql

mysql_config-64 mysql_plugin mysql_upgrade

mysql_config_editor mysqlpump mysqlxtest

[root@localhostmysql]# echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@localhostmysql]# which mysql

/usr/bin/mysql

[root@localhostmysql]# vim /etc/profile

[root@localhostmysql]# . /etc/profile

[root@localhostmysql]# echo $PATH

/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@localhostmysql]# mysql

mysql mysqld-debug mysqlpump

mysqladmin mysqld_multi mysql_secure_installation

mysqlbinlog mysqld_pre_systemd mysqlshow

mysqlcheck mysqld_safe mysqlslap

mysql_client_test mysqldump mysql_ssl_rsa_setup

mysql_client_test_embedded mysqldumpslow mysqltest

mysql_config mysql_embedded mysqltest_embedded

mysql_config-64 mysqlimport mysql_tzinfo_to_sql

mysql_config_editor mysql_install_db mysql_upgrade

mysqld mysql_plugin mysqlxtest

[root@localhostmysql]# tail -1 /etc/profile

exportPATH=/usr/local/mysql/bin:$PATH

[root@localhostmysql]# mv /etc/my.cnf /etc/my.cnf.bak

[root@localhostmysql]# vim /etc/my.cnf

[root@localhostmysql]# mkdir /dir3307

[root@localhostmysql]# mkdir /dir3308

[root@localhostmysql]# ls /dir330*

/dir3307:


/dir3308:

[root@localhostmysql]# ls /dir330* -l

/dir3307:

总用量0


/dir3308:

总用量0

[root@localhostmysql]# ls /dir330* -ld

drwxr-xr-x.2 root root 6 7521:48 /dir3307

drwxr-xr-x.2 root root 6 7521:48 /dir3308

[root@localhostmysql]# chown mysql:mysql /dir330*

[root@localhostmysql]# ls /dir330* -ld

drwxr-xr-x.2 mysql mysql 6 7521:48 /dir3307

drwxr-xr-x.2 mysql mysql 6 7521:48 /dir3308

[root@localhostmysql]# chown -R mysql:mysql /dir330*

[root@localhostmysql]# ls /dir330* -ld

drwxr-xr-x.2 mysql mysql 6 7521:48 /dir3307

drwxr-xr-x.2 mysql mysql 6 7521:48 /dir3308

[root@localhostmysql]# grep mysql /etc/passwd

mysql:x:27:27:MySQLServer:/var/lib/mysql:/bin/false

[root@localhostmysql]# mysql

mysql mysqld-debug mysqlpump

mysqladmin mysqld_multi mysql_secure_installation

mysqlbinlog mysqld_pre_systemd mysqlshow

mysqlcheck mysqld_safe mysqlslap

mysql_client_test mysqldump mysql_ssl_rsa_setup

mysql_client_test_embedded mysqldumpslow mysqltest

mysql_config mysql_embedded mysqltest_embedded

mysql_config-64 mysqlimport mysql_tzinfo_to_sql

mysql_config_editor mysql_install_db mysql_upgrade

mysqld mysql_plugin mysqlxtest

[root@localhostmysql]# mysqld --user=mysql --basedir=/usr/local/mysql--datadir=/dir3307 --initialize

2018-07-05T13:52:32.418067Z0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (seedocumentation for more details).

2018-07-05T13:52:34.158835Z0 [Warning] InnoDB: New log files created, LSN=45790

2018-07-05T13:52:34.536871Z0 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-07-05T13:52:34.689226Z0 [Warning] No existing UUID has been found, so we assume that thisis the first time that this server has been started. Generating a newUUID: ab76a720-805a-11e8-9617-525400450a69.

2018-07-05T13:52:34.703613Z0 [Warning] Gtid table is not ready to be used. Table'mysql.gtid_executed' cannot be opened.

2018-07-05T13:52:34.704947Z1 [Note] A temporary password is generated for root@localhost:w9g#O2)o/;BS

[root@localhostmysql]# ss -utlpn | grep :3307

[root@localhostmysql]# mysql

mysql mysqld-debug mysqlpump

mysqladmin mysqld_multi mysql_secure_installation

mysqlbinlog mysqld_pre_systemd mysqlshow

mysqlcheck mysqld_safe mysqlslap

mysql_client_test mysqldump mysql_ssl_rsa_setup

mysql_client_test_embedded mysqldumpslow mysqltest

mysql_config mysql_embedded mysqltest_embedded

mysql_config-64 mysqlimport mysql_tzinfo_to_sql

mysql_config_editor mysql_install_db mysql_upgrade

mysqld mysql_plugin mysqlxtest

[root@localhostmysql]# mysqld --user=mysql --basedir=/usr/local/mysql--datadir=/dir3308 --initialize

2018-07-05T13:55:40.651743Z0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (seedocumentation for more details).

2018-07-05T13:55:42.408493Z0 [Warning] InnoDB: New log files created, LSN=45790

2018-07-05T13:55:42.826206Z0 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-07-05T13:55:42.994504Z0 [Warning] No existing UUID has been found, so we assume that thisis the first time that this server has been started. Generating a newUUID: 1bb3c202-805b-11e8-9b48-525400450a69.

2018-07-05T13:55:43.019764Z0 [Warning] Gtid table is not ready to be used. Table'mysql.gtid_executed' cannot be opened.

2018-07-05T13:55:43.021091Z1 [Note] A temporary password is generated for root@localhost:o7M.z./grF!=

[root@localhostmysql]# mysqld_multi start 1

[root@localhostmysql]# ls /dir3307

auto.cnf ibdata1 ib_logfile1 mysql mysqld3307.sock.lock mysqld.pid sys

ib_buffer_pool ib_logfile0 ibtmp1 mysqld3307.sock mysqld.err performance_schema

[root@localhostmysql]# ls /dir3308

auto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema sys

[root@localhostmysql]# mysqld_multi start 2

[root@localhostmysql]# ls /dir3308

auto.cnf ibdata1 ib_logfile1 mysql mysqld3308.sock.lock mysqld.pid sys

ib_buffer_pool ib_logfile0 ibtmp1 mysqld3308.sock mysqld.err performance_schema

[root@localhostmysql]# mysql -uroot -p'w9g#O2)o/;BS' -S /dir3307/mysqld3307.sock

mysql:[Warning] Using a password on the command line interface can beinsecure.

Welcometo the MySQL monitor. Commands end with ; or \g.

YourMySQL connection id is 3

Serverversion: 5.7.20


Copyright(c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.


Oracleis a registered trademark of Oracle Corporation and/or its

affiliates.Other names may be trademarks of their respective

owners.


Type'help;' or '\h' for help. Type '\c' to clear the current inputstatement.


mysql>\q

Bye

[root@localhostmysql]# mysql -uroot -p'w9g#O2)o/;BS' -S /dir3308/mysqld3308.sock

mysql:[Warning] Using a password on the command line interface can beinsecure.

ERROR1045 (28000): Access denied for user 'root'@'localhost' (usingpassword: YES)

[root@localhostmysql]# mysql -uroot -p'o7M.z./grF!=' -S /dir3308/mysqld3308.sock

mysql:[Warning] Using a password on the command line interface can beinsecure.

Welcometo the MySQL monitor. Commands end with ; or \g.

YourMySQL connection id is 4

Serverversion: 5.7.20


Copyright(c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.


Oracleis a registered trademark of Oracle Corporation and/or its

affiliates.Other names may be trademarks of their respective

owners.


Type'help;' or '\h' for help. Type '\c' to clear the current inputstatement.


mysql>\c

mysql>\q

Bye

[root@localhostmysql]#


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乐于技术分享

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值