[root@db-node1 mysql-5.6.37]# groupadd -g 8000 mysql
[root@db-node1 mysql-5.6.37]# useradd -u 8000 -g 8000 mysql
[root@db-node1 mysql-5.6.37]# id mysql
uid=8000(mysql) gid=8000(mysql) groups=8000(mysql)
[root@db-node1 mysql-5.6.37]# chown -R mysql.mysql /data/dbdata/mysql_3306/ /data/dbdata/mysql_3307/
[root@db-node1 mysql-5.6.37]# ll /data/dbdata/
total 0
drwxr-xr-x 11 mysql mysql 129 Sep 2 22:20 mysql_3306
drwxr-xr-x 11 mysql mysql 129 Sep 2 22:20 mysql_3307
[root@db-node1 mysql-5.6.37]# ll /data/dbdata/*
/data/dbdata/mysql_3306:
total 0
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 binlogs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 etc
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 innodb_data
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 innodb_logs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 logs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 mydata
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 relaylogs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 socket
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 tmp
/data/dbdata/mysql_3307:
total 0
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 binlogs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 etc
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 innodb_data
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 innodb_logs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 logs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 mydata
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 relaylogs
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 socket
drwxr-xr-x 2 mysql mysql 6 Sep 2 22:20 tmp
[root@db-node1 mysql-5.6.37]# mysql -S /data/dbdata/mysql_3306/socket/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.37-log Source distribution
Copyright (c) 2000, 2017, 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> \q
Bye
指定ip地址和端口登录,适合远程连接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@db-node1 mysql-5.6.37]# mysql -h 127.0.0.1 -P3306
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.37-log Source distribution
Copyright (c) 2000, 2017, 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> \q
Bye
[root@db-node1 mysql-5.6.37]# mysqladmin -h 127.0.0.1 -P3306 -uroot password '123456'
Warning: Using a password on the command line interface can be insecure.
[root@db-node1 mysql-5.6.37]# mysqladmin -S /data/dbdata/mysql_3306/socket/mysql.sock -uroot password '123456'
Warning: Using a password on the command line interface can be insecure.
[root@db-node1 mysql-5.6.37]# mysql -S /data/dbdata/mysql_3306/socket/mysql.sock -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.37-log Source distribution
Copyright (c) 2000, 2017, 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 |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> drop database test;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+------------------------+-------------------------------------------+
| user | host | password |
+------+------------------------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | db-node1.devopssec.cn | |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | ::1 | |
| | localhost | |
| | db-node1.devopssec.cn | |
+------+------------------------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> drop user 'root'@'db-node1.devopssec.cn';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user 'root'@'::1';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'db-node1.devopssec.cn';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+-----------+-------------------------------------------+
2 rows in set (0.00 sec)
[root@db-node1 mysql-5.6.37]# mysqladmin -h 127.0.0.1 -P3307 -uroot password '123456'
Warning: Using a password on the command line interface can be insecure.
[root@db-node1 mysql-5.6.37]# mysqladmin -S /data/dbdata/mysql_3307/socket/mysql.sock -uroot password '123456'
Warning: Using a password on the command line interface can be insecure.
[root@db-node1 mysql-5.6.37]# mysql -S /data/dbdata/mysql_3307/socket/mysql.sock -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.37-log Source distribution
Copyright (c) 2000, 2017, 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 |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> drop database test;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+------------------------+-------------------------------------------+
| user | host | password |
+------+------------------------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | db-node1.devopssec.cn | |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | ::1 | |
| | localhost | |
| | db-node1.devopssec.cn | |
+------+------------------------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> drop user 'root'@'db-node1.devopssec.cn';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user 'root'@'::1';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'db-node1.devopssec.cn';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+-----------+-------------------------------------------+
2 rows in set (0.00 sec)