mysql安装过程记录和后续学习

1、在百度软件中心下载mysql,或去Oracle官网(下载很慢),其实都一样,解压缩后。

2、配置了PATH环境变量,就是可以在任意路径执行mysql命令

3、cmd命令行mysql 报错 ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

之前装过,知道是mysql服务没起来。右键我的电脑,点击“管理”,找到服务,看一下没有安装mysql服务。

4、在mysql安装根路径下,添加一个my.ini文件。

[mysqld]
basedir = D:\Program Files (x86)\mysql-5.6.24-win32
datadir = D:\Program Files (x86)\mysql-5.6.24-win32\data

具体可以查看同路径下的my-default.ini

5、命令行mysqld -install提示  服务安装成功

6、启动服务,大功告成。


截图:

mysql安装过程记录和后续学习_第1张图片


修改root密码,刚开始root没有密码。

使用命令mysqladmin -uroot password 123456 设置密码为123456;

C:\Documents and Settings\Administrator>mysqladmin -uroot password 123456
Warning: Using a password on the command line interface can be insecure.


C:\Documents and Settings\Administrator>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.24 MySQL Community Server (GPL)


Copyright (c) 2000, 2015, 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>


2015-12-20自己验证mysql导入文本文件和导出文本文件

参考:http://www.jb51.net/article/21117.htm

--导出文本文件  select name,deptNo into outfile "E:\data_out.txt" lines terminated by "\r\n" from student;

C:\Users\lenovo>mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.6.24 MySQL Community Server (GPL)


Copyright (c) 2000, 2015, 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 name,deptNo into outfile "E:\data_out.txt" lines terminated by "\r\n" from student;
ERROR 1046 (3D000): No database selected
mysql> use test;
Database changed
mysql> select name,deptNo into outfile "E:\data_out.txt" lines terminated by "\r\n" from student;
Query OK, 2 rows affected (0.06 sec)

其中lines terminated by “\r\n”表示每一行(即每一条记录)用\r\n分隔,\r\n是window系 
统的换行符。

mysql> truncate table student;
Query OK, 0 rows affected (0.42 sec)


mysql> select * from student;
Empty set (0.00 sec)

--导入文件,可以用于数据量很大场景,先写到文件中,后续批量插入到数据库
mysql> load data local infile "e:\data_out.txt" into table student (name,deptNo);
Query OK, 2 rows affected (0.06 sec)
Records: 2  Deleted: 0  Skipped: 0  Warnings: 0


mysql> select * from student;
+----+------------+--------+
| id | name       | deptNo |
+----+------------+--------+
|  1 | ZhangQiang |      1 |
|  2 | Kobe1      |      5 |
+----+------------+--------+
2 rows in set (0.00 sec)

你可能感兴趣的:(mysql,安装)