yum 安装的mysql8多实例
- 初始化的时候,不需要指定basedir。yum安装的默认会去/usr/share/mysql-8.0/,指定basedir后会报错Can't find error-message file。
初始化命令:
# /usr/sbin/mysqld --defaults-file=/etc/sitmy.cnf --user=mysql --datadir=/var/lib/mysql3307/data --initialize-insecure
- mysql8的配置需要增加mysqlx插件配置:
mysqlx_port = 33070 和 mysqlx_socket=mysqlx.sock路径
# grep -v "#" /etc/sitmy.cnf
[client]
port=3307
[mysqld]
port=3307
mysqlx_port = 33070
lower_case_table_names = 1
datadir=/var/lib/mysql3307/data
socket=/var/lib/mysql3307/mysql.sock
mysqlx_socket=/var/lib/mysql3307/mysqlx.sock
log-error=/var/log/mysqld3307.log
pid-file=/var/run/mysqld/mysqld3307.pid
[root@vonedao1 data]# pwd
/var/lib/mysql3307/data
3 . 启动命令:
# /usr/sbin/mysqld --defaults-file=/etc/sitmy.cnf --user=mysql&
-
检查
-
登录
# mysql -uroot -S /var/lib/mysql3307/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql>
- 添加用户并授权
mysql> use mysql;
mysql> create user 'sit'@'%' identified by '密码';
mysql> ALTER USER 'sit'@'%' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;
mysql> ALTER USER 'sit'@'%' IDENTIFIED WITH mysql_native_password BY '密码';
mysql> grant all privileges on *.* to 'sit'@'%';
mysql> flush privileges;