--启动数据库: /etc/init.d/mysql start Starting MySQL.Logging to '/data/mysql/error.log'. SUCCESS!
vim /etc/profile.d/mysql.sh cat /etc/profile.d/mysql.sh export PATH=$PATH:/usr/local/mysql/bin source /etc/profile.d/mysql.sh mysqld --version mysqld Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL) [root@node4 mysql]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 7 Server version: 8.0.12 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> select version(); +-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)
7.设置可以远程登录的账号: mysql> show variables like '%valid%pass%'; Empty set (0.00 sec) mysql> create user root@'%' identified by 'oracle'; ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> show variables like '%valid%pass%'; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql> alter user root@'localhost' identified by 'oracle'; Query OK, 0 rows affected (0.07 sec) mysql> show variables like '%valid%pass%'; Empty set (0.01 sec)
--创建可以远程登录的用户: mysql> create user root@'%' identified by 'oracle'; Query OK, 0 rows affected (0.06 sec) mysql> grant all privileges on . to root@'%' with grant option; Query OK, 0 rows affected (0.07 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
复制到 root@localhost home]# mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql [root@localhost home]# 配置文件: [root@localhost mysql]# [root@localhost mysql]# [root@localhost mysql]# cd /etc/ [root@localhost etc]# mv my.cnf my.cnf.bak [root@localhost etc]# vim my.cnf [mysqld] server-id = 1 port = 3306 mysqlx_port = 33060 mysqlx_socket = /tmp/mysqlx.sock datadir = /data/mysql socket = /tmp/mysql.sock pid-file = /tmp/mysqld.pid log-error = error.log slow-query-log = 1 slow-query-log-file = slow.log long_query_time = 0.2 log-bin = bin.log relay-log = relay.log binlog_format =ROW relay_log_recovery = 1 character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init_connect ='SET NAMES utf8mb4' innodb_buffer_pool_size = 1G join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M log_timestamps = SYSTEM lower_case_table_names = 1 default-authentication-plugin =mysql_native_password ~ "my.cnf" [新] 27L, 1083C 已写入 [root@localhost etc]# [root@localhost etc]# [root@localhost etc]# [root@localhost etc]# [root@localhost etc]# mkdir -p /data/mysql [root@localhost etc]# chown -R mysql:mysql /data/mysql/ [root@localhost etc]# chmod -R 775 /data/mysql/ [root@localhost etc]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure [root@localhost etc]# cat /data/mysql/error.log | grep -i password 2018-08-25T21:10:11.470522+08:00 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. ~ "profile.d/mysql.sh" [新] 2L, 69C 已写入 [root@localhost etc]# [root@localhost etc]# source /etc/profile.d/mysql.sh [root@localhost etc]# [root@localhost etc]# mysqld --version mysqld Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL) [root@localhost etc]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 8 Server version: 8.0.12 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> select version(); +-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)
mysql> show variables like '%valid%pass%'; Empty set (0.02 sec)
mysql> show variables like '%valid%pass%'; Empty set (0.02 sec)
mysql> create user root@'%' identified by 'admin'; Query OK, 0 rows affected (0.10 sec)
mysql> alter user root@'localhost' identified by 'admin'; Query OK, 0 rows affected (0.05 sec)
mysql> show variables like '%valid%pass%'; Empty set (0.01 sec)
mysql> create user root@'%' identified by 'admin'; ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'%' mysql> grant all privileges on . to root@'%' with grant option; Query OK, 0 rows affected (0.08 sec)