此时3306的data文件夹是空的,没有数据
root@centOS78 ~]# ls /my_mysql/3306/data/
执行初始化,生成MySQL运行所需的初始化数据
/application/mysql-5.6.40-linux-glibc2.12-x86_64/scripts/mysql_install_db --defaults-file=/my_mysql/3306/my.cnf --basedir=/application/mysql-5.6.40-linux-glibc2.12-x86_64/ --datadir=/my_mysql/3306/data/ --user=mysql
注意:
出现两个OK后表示正常
此时会正确生成MySQL的初始数据
root@centOS78 ~]# ls -l /my_mysql/3306/data/
total 110604
-rw-rw---- 1 mysql mysql 56 Aug 2720:47 auto.cnf
-rw-rw---- 1 mysql mysql 12582912 Aug 2721:44 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Aug 2721:44 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Aug 2719:50 ib_logfile1
drwx------ 2 mysql mysql 20 Aug 2721:15 lin1
drwx------ 2 mysql mysql 4096 Aug 2719:50 mysql
drwx------ 2 mysql mysql 4096 Aug 2720:29 performance_schema
drwx------ 2 mysql mysql 6 Aug 2719:50 test
2.初始化3307的数据
此时3306的data文件夹是空的,没有数据
root@centOS78 ~]# ls /my_mysql/3307/data/
执行初始化,生成MySQL运行所需的初始化数据
/application/mysql-5.6.40-linux-glibc2.12-x86_64/scripts/mysql_install_db --defaults-file=/my_mysql/3307/my.cnf --basedir=/application/mysql-5.6.40-linux-glibc2.12-x86_64/ --datadir=/my_mysql/3307/data/ --user=mysql
注意:
出现两个OK后表示正常
此时会正确生成MySQL的初始数据
root@centOS78 ~]# ls -l /my_mysql/3307/data/
total 110604
-rw-rw---- 1 mysql mysql 56 Aug 2720:48 auto.cnf
-rw-rw---- 1 mysql mysql 12582912 Aug 2721:47 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Aug 2721:47 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Aug 2719:50 ib_logfile1
drwx------ 2 mysql mysql 4096 Aug 2719:50 mysql
drwx------ 2 mysql mysql 4096 Aug 2720:30 performance_schema
drwx------ 2 mysql mysql 6 Aug 2719:50 test
确保当前没有其他MySQL
root@centOS78 ~]# netstat -tunlp |grep mysql
root@centOS78 ~]# /my_mysql/3306/mysql_3306
Usage: /data/3306/mysql{start|stop|restart}
root@centOS78 ~]# /my_mysql/3306/mysql_3306 start
MySQL is running...
用如下命令登录,使用sock套接字文件登录
root@centOS78 ~]# mysql -S /my_mysql/3307/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.40-log MySQL Community Server (GPL)
Copyright (c)2000, 2018, Oracle and/or its affiliates. All
rights reserved.
Oracle is 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
input statement.
mysql>
mysql>
mysql>
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema || mysql || performance_schema ||test|
+--------------------+
4 rows inset(0.00 sec)
mysql> show databases;
2.启动3307数据库
确保当前没有其他MySQL
root@centOS78 ~]# netstat -tunlp |grep mysql
root@centOS78 ~]# /my_mysql/3307/mysql_3307
Usage: /data/3307/mysql{start|stop|restart}
root@centOS78 ~]# /my_mysql/3307/mysql_3307 start
MySQL is running...
用如下命令登录,使用sock套接字文件登录
root@centOS78 ~]# mysql -S /my_mysql/3307/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.40-log MySQL Community Server (GPL)
Copyright (c)2000, 2018, Oracle and/or its affiliates. All
rights reserved.
Oracle is 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
input statement.
mysql>
mysql>
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema || mysql || performance_schema ||test|
+--------------------+
4 rows inset(0.00 sec)
mysql> show databases;