bitsCN.com
一、连接MYSQL。格式: mysql -h主机地址 -u用户名 -p用户密码1、连接到本机上的MYSQL。首先打开DOS窗口,然后进入目录mysql/bin,再键入命令mysql -uroot -p,回车后提示你输密码.注意用户名前可以有空格也可以没有空格,但是密码前必须没有空格,否则让你重新输入密码.如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中了,MYSQL的提示符是: mysql>2、连接到远程主机上的MYSQL。 假设远程主机的IP为:110.110.110.110,用户名为root,密码为abcd123。则键入以下命令:mysql -h110.110.110.110 -uroot -p123;(注:u与root之间可以不用加空格,其它也一样)3、退出MYSQL命令: exit (回车)二、修改密码。格式:mysqladmin -u用户名 -p旧密码 password 新密码 (在测试的时候发现没有这个命令,呵呵原来是版本太低了)官网: mysqladmin — Client for Administering a MySQL Serverhttp://dev.mysql.com/doc/refman/5.1/en/mysqladmin.html 1、给root加个密码ab12。首先在DOS下进入目录mysql/bin,然后键入以下命令mysqladmin -u root -password ab12注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。2、再将root的密码改为djg345。mysqladmin -u root -p ab12 password djg345三、增加新用户。(注意:和上面不同,下面的因为是MYSQL环境中的命令,所以后面都带一个分号作为命令结束符)格式:grant select on 数据库.* to 用户名@登录主机 identified by “密码”1、增加一个用户test1密码为abc,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用root用户连入MYSQL,然后键入以下命令:grant select,insert,update,delete on *.* to [email=test1@”%]test1@”%[/email]” Identified by “abc”;但增加的用户是十分危险的,你想如某个人知道test1的密码,那么他就可以在internet上的任何一台电脑上登录你的mysql数据库并对你的数据可以为所欲为了,解决办法见2。2、增加一个用户test2密码为abc,让他只可以在localhost上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作(localhost指本地主机,即MYSQL数据库所在的那台主机),这样用户即使用知道test2的密码,他也无法从internet上直接访问数据库,只能通过MYSQL主机上的web页来访问了。grant select,insert,update,delete on mydb.* to [email=test2@localhost]test2@localhost[/email] identified by “abc”; 如果你不想test2有密码,可以再打一个命令将密码消掉。grant select,insert,update,delete on mydb.* to [email=test2@localhost]test2@localhost[/email] identified by “”;下篇我是MYSQL中有关数据库方面的操作。注意:你必须首先登录到MYSQL中,以下操作都是在MYSQL的提示符下进行的,而且每个命令以分号结束。一、操作技巧1、如果你打命令时,回车后发现忘记加分号,你无须重打一遍命令,只要打个分号回车就可以了。也就是说你可以把一个完整的命令分成几行来打,完后用分号作结束标志就OK。2、你可以使用光标上下键调出以前的命令。二、显示命令1、显示当前数据库服务器中的数据库列表:mysql> SHOW DATABASES;注意:mysql库里面有MYSQL的系统信息,我们改密码和新增用户,实际上就是用这个库进行操作。2、显示数据库中的数据表:mysql> USE 库名;mysql> SHOW TABLES;3、显示数据表的结构:mysql> DESCRIBE 表名;4、建立数据库:mysql> CREATE DATABASE 库名;5、建立数据表:mysql> USE 库名;mysql> CREATE TABLE 表名 (字段名 VARCHAR(20), 字段名 CHAR(1));6、删除数据库: mysql> DROP DATABASE 库名;7、删除数据表:mysql> DROP TABLE 表名;8、将表中记录清空:mysql> DELETE FROM 表名;9、显示表中的记录:mysql> SELECT * FROM 表名;10、往表中插入记录:mysql> INSERT INTO 表名 VALUES (”hyq”,”M”);11、更新表中数据:mysql-> UPDATE 表名 SET 字段名1=’a',字段名2=’b’ WHERE 字段名3=’c';12、用文本方式将数据装入数据表中:mysql> LOAD DATA LOCAL INFILE “D:/mysql.txt” INTO TABLE 表名;13、导入.sql文件命令:mysql> USE 数据库名;mysql> SOURCE d:/mysql.sql;14、命令行修改root密码:mysql> UPDATE mysql.user SET password=PASSWORD(’新密码’) WHERE User=’root’;mysql> FLUSH PRIVILEGES;15、显示use的数据库名:mysql> SELECT DATABASE();16、显示当前的user:mysql> SELECT USER(); 新加:当前使用状态mysql>statusmysql Ver 14.12 Distrib 5.0.45, for Win32 (ia32)Connection id: 6Current database: 数据库名Current user: root@localhostSSL: Not in useUsing delimiter: ; Server version: 5.0.45-community-nt-log MySQL Community Edition (GPL)Protocol version: 10Connection: localhost via TCP/IPServer characterset: utf8Db characterset: utf8Client characterset: utf8Conn. characterset: utf8TCP port: 3306Uptime: 35 min 48 sec 三、一个建库和建表以及插入数据的实例drop database if exists school; //如果存在SCHOOL则删除create database school; //建立库SCHOOLuse school; //打开库SCHOOLcreate table teacher //建立表TEACHER(id int(3) auto_increment not null primary key,name char(10) not null, address varchar(50) default ‘深圳’,year date); //建表结束//以下为插入字段insert into teacher values(”,’allen’,'大连一中’,'1976-10-10′);insert into teacher values(”,’jack’,'大连二中’,'1975-12-23′);如果你在mysql提示符键入上面的命令也可以,但不方便调试。(1)你可以将以上命令原样写入一个文本文件中,假设为school.sql,然后复制到c://下,并在DOS状态进入目录[url=file:////mysql//bin]//mysql//bin[/url],然后键入以下命令:mysql -uroot -p密码 source c://school.sql; 也可以将school.sql文件导入数据库中。四、将文本数据转到数据库中1、文本数据应符合的格式:字段数据之间用tab键隔开,null值用[url=file:////n]//n[/url]来代替.例:3 rose 大连二中 1976-10-104 mike 大连一中 1975-12-23假设你把这两组数据存为school.txt文件,放在c盘根目录下。2、数据传入命令 load data local infile “c://school.txt” into table 表名;注意:你最好将文件复制到[url=file:////mysql//bin]//mysql//bin[/url]目录下,并且要先用use命令打表所在的库。 五、备份数据库:(命令在DOS的[url=file:////mysql//bin]//mysql//bin[/url]目录下执行)1.导出整个数据库导出文件默认是存在mysql/bin目录下mysqldump -u 用户名 -p 数据库名 > 导出的文件名mysqldump -u user_name -p123456 database_name > outfile_name.sql2.导出一个表mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名mysqldump -u user_name -p database_name table_name > outfile_name.sql3.导出一个数据库结构mysqldump -u user_name -p -d –add-drop-table database_name > outfile_name.sql-d 没有数据 –add-drop-table 在每个create语句之前增加一个drop table4.带语言参数导出mysqldump -uroot -p –default-character-set=latin1 –set-charset=gbk –skip-opt database_name > outfile_name.sql 作者 wenjinglian bitsCN.com

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.

MySQL is suitable for beginners because: 1) easy to install and configure, 2) rich learning resources, 3) intuitive SQL syntax, 4) powerful tool support. Nevertheless, beginners need to overcome challenges such as database design, query optimization, security management, and data backup.

Yes,SQLisaprogramminglanguagespecializedfordatamanagement.1)It'sdeclarative,focusingonwhattoachieveratherthanhow.2)SQLisessentialforquerying,inserting,updating,anddeletingdatainrelationaldatabases.3)Whileuser-friendly,itrequiresoptimizationtoavoidper

ACID attributes include atomicity, consistency, isolation and durability, and are the cornerstone of database design. 1. Atomicity ensures that the transaction is either completely successful or completely failed. 2. Consistency ensures that the database remains consistent before and after a transaction. 3. Isolation ensures that transactions do not interfere with each other. 4. Persistence ensures that data is permanently saved after transaction submission.

MySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.

MySQL uses SQL commands to manage data. 1. Basic commands include SELECT, INSERT, UPDATE and DELETE. 2. Advanced usage involves JOIN, subquery and aggregate functions. 3. Common errors include syntax, logic and performance issues. 4. Optimization tips include using indexes, avoiding SELECT* and using LIMIT.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version