The MySQL database
MySQL can be seen as a software support remote file operations.
Library folder >>>
Table >>> file
>>> record data in a file line by line, called a section of the recording
Header: is the first row of the table
Fields: Field Name Field Type +
Nature: a Web-based software to communicate
Any software-based network communication, are the underlying socket
Server:
- socket-based communication
- messaging
-SQL statement (a common standard)
Client:
- socket-based communication
- messaging
-SQL statement
ps: MySQL not only supports MySQL client to operate, but also support other languages direct manipulation. Python, Java, php syntax is not the same, the specified standard SQL.
DBMS: Database Management System
Relational databases: association between data and data limitations and can
MySQL,oracle,sqlite,db2,sql server
Relational database table structure usually means the use of a relational database, the first step is to determine the relationship structure.
Field has a specific type.
Non-relational databases: usually at k / v stored key-value pairs of data.
redis, mongodb (document database, very close relationship type of non-relational databases), memcache
MySQL file structure:
bin: execution folder
mysqld server
mysql client
docs: Documentation
lib: Libraries
data: the folder where the database
Common Operations
mysql statement in order; the end.
When the wrong sql statement input \ c exit
Client Login: mysql -h 127.0.0.1 -P 3306 -uroot -p
Can be abbreviated: mysql -uroot -p
If you do not enter a user name and password can also go in, the default is landed guest mode function can be used rarely
Client Exit: exit / quit
The windows system, mysqld server needs to be made into a system service
mysqld --install
change Password
set password=password('your password')
alter user 'root'@'localhost' identified by 'Quattro!';
Profiles
\ S View mysql server simple configuration
Usually suffix configuration files are ini the end of the case
mysql configuration file that comes with not modified, but can create a new my.ini file, mysql server at startup will automatically load your my.ini configuration file inside the configuration. linux system is to create a my.cnf file
1, create a configuration file my.cnf file in the mysql directory
2, modify the my.cnf file permissions to 777: sudo chmod 777 my.cnf
3. Fill in the configuration information
[mysqld] character-set-server=utf8 collation-server=utf8_general_ci [client] default-character-set=utf8 [mysql] user='root' password=123 default-character-set=utf8
4, modify the file permissions to 664: sudo chmod 664 my.cnf. Because the file permissions are only 664, mysql only considered safe.
5, restart the mysql server
Finished modifying the configuration files need to restart the server to take effect.
reads the configuration file during the boot sequence is under linux Mysql
1./etc/my.cnf
2./etc/mysql/my.cnf
3./usr/local/mysql/etc/my.cnf (own mysql installation directory )
4. ~ / the my.cnf
The basic operation of the database:
Library: similar to folders
increase
create database db1;
check
show databases; Database View all
show create database db1; view a single database
change
alter database db1 charset = 'gbk'; modified encoding
delete
drop database db1; deleted
table:
You need to specify the library when you create the table: use library name
View the current library resides: select database ();
increase
create table userinfo(id int, name char);
check
show tables; see all the tables in this database
show create table userinfo; single table view
desc userinfo; <=> describe userinfo;
change
alter table userinfo modify name char(32);
delete
drop table userinfo;
recording
increase
insert into userinfo values(1,2),(3,4)
check
select * from userinfo
select name from userinfo
select id, name from userinfo where id=1 or name=tank
change
update userinfo set name='1' where id=1
update userinfo set name='1', password='2' where id=1
delete
delete from userinfo where id=1;
delete from userinfo;