1、mysql -h host -u user -p
2、密码:root
3、quit退出。
4、mysql> SELECT VERSION(), CURRENT_DATE;
-------------------------------------密码已经设置好了,但是还出现下面这个问题------------------------------------------------------------------------------
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
------------------------------------从新设置一下,可以了-----------------------------------------------------------------------------------------------------------------
mysql> SET PASSWORD = PASSWORD('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SELECT VERSION(), CURRENT_DATE;
+-----------+--------------+
| VERSION() | CURRENT_DATE |
+-----------+--------------+
| 5.7.20 | 2017-11-21 |
+-----------+--------------+
1 row in set (0.00 sec)
5、使用SHOW语句找出服务器上当前存在什么数据库:
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
6、CREATE DATABASE springdemo;