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

本文介绍MySQL的安装步骤及常见错误解决方法,并演示如何通过命令行进行数据的导入和导出操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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、启动服务,大功告成。


截图:



修改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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值