sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES //支持模塊 [root@localhost mysql-5.7.17]# chown mysql:mysql /etc/my.cnf //修改文件屬主屬組 [root@localhost mysql-5.7.17]# 9.將mysql相關命令添加本地環境配置中 [root@localhost mysql-5.7.17]# echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile //將MySQL寫到本地環境配置中 [root@localhost mysql-5.7.17]# echo 'export PATH' >> /etc/profile //設置全局環境配置 [root@localhost mysql-5.7.17]# source /etc/profile //重新加載配置文件 [root@localhost mysql-5.7.17]# 10.初始化數據庫 [root@localhost mysql-5.7.17]# cd /usr/local/mysql/ [root@localhost mysql]# bin/mysqld / > --initialize-insecure / //初始化 > --user=mysql / //用戶 > --basedir=/usr/local/mysql / //安裝目錄 > --datadir=/usr/local/mysql/data //數據庫數據文件目錄 11.將MySQL服務配置文件復制到/usr/lib/systemd/system/下便于使用systemctl管理 [root@localhost mysql]# cp usr/lib/systemd/system/mysqld.service /lib/systemd/system/ //復制 [root@localhost mysql]# systemctl daemon-reload //重新加載 [root@localhost mysql]# systemctl start mysqld.service //啟動服務 [root@localhost mysql]# netstat -ntap | grep 3306 //查看tcp3306端口 tcp6 0 0 :::3306 :::* LISTEN 78684/mysqld [root@localhost mysql]# systemctl enable mysqld.service //設置開機自啟 Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service. [root@localhost mysql]# 12.配置MySQL密碼 [root@localhost mysql]# mysqladmin -u root -p password Enter password: New password: Confirm new password: Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety. [root@localhost mysql]# 13.嘗試登陸MySQL數據庫 [root@localhost mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 4 Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, 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> grant all privileges on *.* to 'root'@'%' identified by 'abc123' with grant option; //提權讓所有終端能夠遠程登錄 Query OK, 0 rows affected, 1 warning (0.00 sec)
15.進入數據庫查看所有database [root@localhost mysql]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 6 Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, 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.00 sec)