Java Web基础入门,Springboot入门(7)

2019-06-15 00:00:00 java 基础 入门

《Java Web基础入门,Springboot入门(7)》

《Java Web基础入门,Springboot入门(7)》


前言

语言都是相通的,只要搞清楚概念后就可以编写代码了。而概念是需要学习成本的。

本文首发于博客园-Ryan Miao. 由于限制2000字,只能分多篇。


引入MySQL/MariaDB

MySQL被Oracle收走之后,他的father另外创建了新的社区分支MariaDB, 据说用法和MySQL一致。然后,各大Linux开源系统都预置了MariaDB。 当然,由于新出没多久,市场还不够开阔。根据[DB-Engines Ranking]发布的2017年11月份排行, MySQL几乎完全接近Oracle,排名第二。而MariaDB的上升之路还比较遥远。So,还是入手MySQL靠谱。因为开源技术的掌握能力和跳槽能力成正相关。

安装MySQL

MAC安装参考Mac install MySQL。

Windows安装

去官网下载安装包(mysql-5.7.20-winx64.zip). 当然,需要先注册oracle账号。

解压当目录,然后将bin目录加入环境变量,同Java设置环境变量。这里再次演示下。复制bin目录地址,我的为D:\data\mysql\mysql-5.7.20-winx64\bin, 在此电脑右键,–> 属性 –> 高级系统设置 –> 高级 –> 环境变量 –> 在系统环境变量中找到path –> 新建 –> 填入 –> 确认。

然后,重新打开cmd。输入mysqld --initialize --console

C:\Users\Ryan
λ mysqld --initialize --console
mysqld: Could not create or access the registry key needed for the MySQL application
to log to the Windows EventLog. Run the application with sufficient
privileges once to create the key, add the key manually, or turn off
logging for that application.
2017-11-26T05:22:48.434089Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-11-26T05:22:48.437096Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
2017-11-26T05:22:49.148986Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-11-26T05:22:49.276866Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-11-26T05:22:49.370828Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d7e6ac05-d269-11e7-a91e-9883891ed8e3.
2017-11-26T05:22:49.383970Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-11-26T05:22:49.398975Z 1 [Note] A temporary password is generated for root@localhost: /r.Vtktfl9FN

复制我们的临时密码/r.Vtktfl9FN.

命令行启动MySQL:

mysqld --console

新开一个cmd,命令行输入账号密码mysql -u root -p

C:\Users\Ryan
λ mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20

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>

然后就连接到MySQL了。第一个命令行就是启动mysql,第二个命令行就是client,连接MySQL。现在修改我们的root密码

mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

然后,关闭client,输入exit退出。 重新以新密码123456登陆(不要自己难为自己,设置密码为123456是最佳选择).

确认成功就安装完毕。账号为root, 密码为123456

基本操作

关于MySQL的基本语法,学习http://www.runoob.com/mysql/mysql-tutorial.html 即可。

这里简单记录几个简单的概念。

下一篇,简单的SQL增删改查。

相关文章